Commit fc2a89b19aab935ddc0da4d56082348b5e6548cd

Authored by rsimonin
1 parent 7a7157b0

con

Showing 1 changed file with 10 additions and 11 deletions   Show diff stats
@@ -45,7 +45,7 @@ void cons_dico(struct dico **ppt_dico,char val){ @@ -45,7 +45,7 @@ void cons_dico(struct dico **ppt_dico,char val){
45 } 45 }
46 46
47 void ini_dico(struct dico * pt_dico){ 47 void ini_dico(struct dico * pt_dico){
48 - printf("ini_dico"); 48 + printf("ini_dico\n");
49 for(int i=0;i<26;i++){ 49 for(int i=0;i<26;i++){
50 cons_dico(&pt_dico,'a'+i); 50 cons_dico(&pt_dico,'a'+i);
51 } 51 }
@@ -61,27 +61,26 @@ void ajout_mot(struct arbre **pt_arbre,char *mot, int i){ @@ -61,27 +61,26 @@ void ajout_mot(struct arbre **pt_arbre,char *mot, int i){
61 Arbre *monarbre=malloc(sizeof(struct arbre)); 61 Arbre *monarbre=malloc(sizeof(struct arbre));
62 monarbre->val=mot[i]; 62 monarbre->val=mot[i];
63 monarbre->finmot=false; 63 monarbre->finmot=false;
64 - for(int i=0;i<26;i++){  
65 - monarbre->suite[i]=NULL; 64 + for(int j=0;j<26;j++){
  65 + monarbre->suite[j]=NULL;
66 } 66 }
67 pt_arbre=&monarbre; 67 pt_arbre=&monarbre;
68 printf("%c\n",(*pt_arbre)->val); 68 printf("%c\n",(*pt_arbre)->val);
69 69
70 } 70 }
71 i++; 71 i++;
72 - ajout_mot(pt_arbre,mot,i); 72 + ajout_mot(&((*pt_arbre)->suite[mot[i]-'a']),mot,i);
73 } 73 }
74 -// (*pt_arbre)->finmot=true;  
75 -// printf("true\n"); 74 +
76 } 75 }
77 76
78 void charger_arbre(FILE *fp, struct dico **ppt_dico) 77 void charger_arbre(FILE *fp, struct dico **ppt_dico)
79 { char mot[20]; 78 { char mot[20];
80 ini_dico(*ppt_dico); 79 ini_dico(*ppt_dico);
81 - while (fscanf(fp, "%s", mot)!=EOF){  
82 - printf("\nmot:%s\n",mot);  
83 - printf("%c\n",(*ppt_dico)->alpha[mot[0]-'a']->val);  
84 - ajout_mot(&((*ppt_dico)->alpha[mot[0]-'a']),mot,0); 80 + while (fscanf(fp, "%s", mot)==1){
  81 + int i=0;
  82 + printf("mot:%s\n",mot);
  83 + ajout_mot(&((*ppt_dico)->alpha[mot[0]-'a']),mot,i);
85 } 84 }
86 return ; 85 return ;
87 } 86 }
@@ -126,7 +125,7 @@ void affiche_dico(struct dico *dico){ @@ -126,7 +125,7 @@ void affiche_dico(struct dico *dico){
126 } 125 }
127 printf("---------------------------------------\n"); 126 printf("---------------------------------------\n");
128 for(int i=0;i<26;i++){ 127 for(int i=0;i<26;i++){
129 - printf("%dmot:",i); 128 + printf("%d:",i);
130 affiche_arbre(dico->alpha[i]); 129 affiche_arbre(dico->alpha[i]);
131 printf("\n"); 130 printf("\n");
132 } 131 }