Salut ,

j'ai déja posté l'ancienne version du programme sous l'intitulé 'programme à vérifier ,
j'ai fait les changements comme conseillé mais j'obtiens toujours erreur de segmentation :
alors voilà le nouveau code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "structure.h"
 
 
void Lecturefichier ( FILE *f , Module t[]);
void Ecriturefichier ( Module t[]);
 
 
 
 
int main () 
{ 
  Module exemple[LenM]; FILE *f;
  f = fopen ("donnees.csv", "r");
  if ( f == NULL ) 
    {
       printf ("erreur : le fichier ne s'ouvre pas  \n");
       return EXIT_FAILURE;
    }
  Lecturefichier (f,exemple);
  fclose (f);
  Ecriturefichier(exemple);
  return 1;
}
 
 
 
void Lecturefichier ( FILE *f , Module t[])
{
  char *pointeur;
  char *buffer;
  char ch[80];
  char *separateur = {";"};
  int i = 1;
  int valeur ; 
  int j = 1;
  t[1].Mod ="AP11";
 
  while ((fgets (ch,80,f)) != NULL )
    {
      buffer = strdup (ch);
      pointeur = strtok(buffer,separateur);
 
      if ( (strcmp (pointeur,t[i].Mod ))== 0 )
	{
	  t[i].Mod = strdup (pointeur) ;
	  pointeur = strtok (NULL , separateur);
	  t[i].Sem = strdup (pointeur) ;
	  pointeur = strtok (NULL , separateur);
	  t[i].Prom =strdup (pointeur) ;
	  pointeur = strtok (NULL , separateur);
	  t[i].Cord = strdup (pointeur);
	  pointeur = strtok (NULL , separateur);
	  t[i].act[j].Nom =strdup(pointeur) ; 
	  pointeur = strtok (NULL , separateur);
	  sscanf(pointeur,"%d",&valeur);
	  t[i].act[j].Ng = valeur ; 
	  pointeur = strtok (NULL , separateur);
	  sscanf (pointeur ,"%d", &valeur);
	  t[i].act[j].Neg = valeur;
	  pointeur = strtok (NULL , separateur);
	  sscanf (pointeur,"%d", &valeur);
	  t[i].act[j].Nhg = valeur;
	  j++;
	}
     else
	{
	  i++;
          t[i].Mod =strdup (pointeur) ;
	  pointeur = strtok (NULL , separateur);
	  t[i].Sem = strdup (pointeur) ; 
	  pointeur = strtok (NULL , separateur);
	  t[i].Prom =strdup (pointeur);
	  pointeur = strtok (NULL , separateur);
	  t[i].Cord = strdup (pointeur) ;
	  pointeur = strtok (NULL , separateur);
	  t[i].act[j].Nom = strdup (pointeur) ; 
	  pointeur = strtok (NULL , separateur);
	  sscanf(pointeur,"%d",&valeur);
	  t[i].act[j].Ng = valeur ; 
	  pointeur = strtok (NULL , separateur);
	  sscanf (pointeur ,"%d", &valeur);
	  t[i].act[j].Neg = valeur;
	  pointeur = strtok (NULL , separateur);
	  sscanf (pointeur,"%d", &valeur);
	  t[i].act[j].Nhg = valeur;
	}
    }
}
 
 
 
 
 
void Ecriturefichier ( Module t[] )
{
  char nomfich[21];
  int i,j;
  FILE *sortie;
 
  printf ( "nom du fichier à créer : ");
  scanf ( "%20s" , nomfich);
  sortie = fopen (nomfich , "w" );
 
  for ( i=1;i<LenM;i++)
    {
      for ( j=1;j<LenA;j++)
	{
	  fputs (t[i].Mod , sortie ); fputc (';',sortie);
	  fputs (t[i].Sem , sortie ); fputc (';',sortie);
	  fputs (t[i].Prom, sortie ); fputc (';',sortie);
	  fputs (t[i].Cord, sortie ); fputc (';',sortie);
	  fputs (t[i].act[j].Nom, sortie ); fputc (';',sortie);
	   putw (t[i].act[j].Ng , sortie ); fputc (';',sortie);
	   putw (t[i].act[j].Neg, sortie ); fputc (';',sortie);
	   putw (t[i].act[j].Nhg, sortie ); fputc (';',sortie);
	}
    }
  fclose (sortie);
}
pour le module structure ,voilà le code ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
# define LenA 4
 
# define LenM 2
 
FILE *f;
 
typedef struct { char *Nom;
                 int Ng, Neg, Nhg; } Activite ;
 
typedef struct { char *Mod, *Sem, *Prom, *Cord;
  Activite act[LenA]; } Module ; 
 
 
void Lecturefichier ( FILE *f , Module t[]);
 
void Ecrirefichier ( Module t[]);
le fichier est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
"AP11";"SEM1";"EI1";"PROTOY";"COURS";1;1;1
"AP11";"SEM1";"EI1";"PROTOY";"CGROUPE";8;1;30
"AP11";"SEM1";"EI1";"PROTOY";"TD";8;1;34
"AP11";"SEM1";"EI1";"PROTOY";"TP";8;2;65
"UX11";"SEM1";"EI1";"SILBER";"COURS";1;1;1
"UX11";"SEM1";"EI1";"SILBER";"CGROUPE";8;1;26
"UX11";"SEM1";"EI1";"SILBER";"TD";8;1;36
"UX11";"SEM1";"EI1";"SILBER";"TP";8;1;1
enfin le makefile est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
all	:	operationfichier
 
operationfichier	:	operationfichier.o
 
		gcc -Wall operationfichier.o -o operationfichier
 
operationfichier.o	:	operationfichier.c	structure.h
 
		gcc -Wall -c operationfichier.c
 
clean	:
		rm -f *.o operationfichier
qq pourra m'aider à identifier la faute ?
merci