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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAILLE_MAX 64
typedef struct sla {
char employe[TAILLE_MAX],
prenom[TAILLE_MAX],
nom[TAILLE_MAX],
indTelephone[TAILLE_MAX],
telephone[TAILLE_MAX],
indFax[TAILLE_MAX],
fax[TAILLE_MAX],
email[TAILLE_MAX];
}LigneAnnuaire;
int main()
{
char ligne[] = "Renner-Nantz, Jody (530) 752-2906 (530) 753-4759 jjrennernantz@ucdavis.edu";
char *mot;
LigneAnnuaire employe;
mot = strtok(ligne, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.nom,mot);
printf("%s\n",employe.nom);
mot = strtok(NULL, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.prenom,mot);
printf("%s\n",employe.prenom);
mot = strtok(NULL, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.indTelephone,mot);
printf("%s\n",employe.indTelephone);
mot = strtok(NULL, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.telephone,mot);
printf("%s\n",employe.telephone);
mot = strtok(NULL, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.indFax,mot);
printf("%s\n",employe.indFax);
mot = strtok(NULL, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.fax,mot);
printf("%s\n",employe.fax);
mot = strtok(NULL, " ,()");
if(mot == NULL) {
printf("Erreur avec la ligne\n");
return EXIT_FAILURE;
}
strcpy(employe.email,mot);
printf("%s\n",employe.email);
return EXIT_SUCCESS;
} |
Partager