Bonjour
J'essaie de lire un fichier dont chaque ligne est structurée de cette manière :

Renner-Nantz, Jody (530) 752-2906 (530) 753-4759 jjrennernantz@ucdavis.edu

Voici mon 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
 
while (fgets(ligne,MAX_LIGNE,f) != NULL)
	{
		LigneAnnuaire employe;
		employe.nom = (char*) malloc(sizeof(char)*TAILLE_MAX);
		employe.prenom = (char*) malloc(sizeof(char)*TAILLE_MAX);
		employe.indTelephone = (char*) malloc(sizeof(char)*TAILLE_MAX);
		employe.telephone = (char*) malloc(sizeof(char)*TAILLE_MAX);
		employe.indFax = (char*) malloc(sizeof(char)*TAILLE_MAX);
		employe.fax = (char*) malloc(sizeof(char)*TAILLE_MAX);
		employe.email = (char*) malloc(sizeof(char)*TAILLE_MAX);
 
		mot = strtok(ligne, " ,()");
		strcpy(employe.nom,mot);
 
		mot = strtok(NULL, " ,()");
		strcpy(employe.prenom,mot);
 
		mot = strtok(NULL, " ,()");	
		strcpy(employe.indTelephone,mot);
 
		mot = strtok(NULL, " ,()");
		strcpy(employe.telephone,mot);
 
		mot = strtok(NULL, " ,()");
		strcpy(employe.indFax,mot);
 
		mot = strtok(NULL, " ,()");
		strcpy(employe.fax,mot);
 
		mot = strtok(NULL, " ,()");
		strcpy(employe.email,mot);
Bien entendu mon code ne fonctionne pas comme il le faut, il ne coupe pas les mots comme il le faut.
Par exemple je lis Renner-Nantz, ensuite Jody (donc tout va bien) et apres je devrais lire 530 mais je lis un caractere inconnu ! :S

Merci pour tout aide
Mary