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
|
typedef struct MOT {
char *mot1;
unsigned long position;
} *mot;
typedef struct DICTIONNAIRE {
//struct MOT *mot2;
mot *dico;
int nombre;
} *dictionnaire;
dictionnaire index2(FILE *dico_fich) {
dictionnaire d;
int i,h = 0;
char *ligne = (char*) malloc(TAILLE_MAX*sizeof(char));
while (fgets(ligne, TAILLE_MAX, dico_fich)) {
i++;
}
d->nombre = i;
d->dico = (mot*) malloc(i*sizeof(mot));
h = fseek(dico_fich, 0, SEEK_SET);
int j = 0;
while (fgets(ligne, TAILLE_MAX, dico_fich)) {
d->dico[j]->mot1 = strtok(ligne, " ");
d->dico[j]->position = j;
j++;
}
return d;
} |
Partager