| 12
 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
 
 |  
typedef struct 
{
	int price_date ;
	int domaine ; 
	char nom[50];
	int jour_naissance ;
	int mois_naissance ;
	int annee_naissance;
	char nationalite[30];
	char genre[1];
} Nomine_s ;
 
Nomine_s tab[MAXTAB] ;
 
 
int ConstruireTableaux(Nomine_s *tab)
{
	char f[15] ,str[100] ;
	char **tokens ; 
	FILE *fp ;
	int i , c , n ; 
	printf("tapez le nom du fichier \n") ; 
	fgets(f,15,stdin) ;
	fp = fopen(f,"r") ;
	while((c = fgetc(fp)) != EOF) 
	{
		if(c == '\n')
		{
			n++ ;
			tokens = str_split(fgets (str, 100, fp), ',') ;
			if (tokens)
			{
					Nomine_s newnomine; 
					newnomine.price_date = atoi(*(tokens)) ;
					newnomine.domaine = atoi(*(tokens)+1) ;
					strcpy(newnomine.nom , *(tokens)+2) ;
					newnomine.jour_naissance = atoi(*(tokens)+3) ;
					newnomine.mois_naissance = atoi(*(tokens)+4) ;
					newnomine.annee_naissance = atoi(*(tokens)+5) ;
					strcpy(newnomine.nationalite , *(tokens)+6 );
					strcpy(newnomine.genre, *(tokens)+7) ;
 
			}
			tab[n-1] = newnomine;
 
		}
	}
	return n ;
} | 
Partager