Commit 2e977567d8f67d591b90f200a629eb550c20bd61

Authored by rsSimonin
1 parent d6bcca7a

2 commit

Showing 1 changed file with 30 additions and 2 deletions   Show diff stats
@@ -49,8 +49,12 @@ void cons_dico(struct dico **pt_dico,char val){ @@ -49,8 +49,12 @@ void cons_dico(struct dico **pt_dico,char val){
49 49
50 void cons_arbre(struct arbre **pt_arbre,char val){ 50 void cons_arbre(struct arbre **pt_arbre,char val){
51 struct arbre *monarbre=malloc(sizeof(struct arbre)); 51 struct arbre *monarbre=malloc(sizeof(struct arbre));
52 - monarbre->suite[val-97]->val=val; // (ascii)->a = 97  
53 - 52 + monarbre->val=val; // (ascii)->a = 97
  53 + for(int i=0;i<26;i++){
  54 + monarbre->suite[i]=NULL;
  55 + }
  56 + monarbre->finmot=false;
  57 + (*pt_arbre)=monarbre;
54 } 58 }
55 59
56 60
@@ -60,7 +64,31 @@ void ini_dico(struct dico * pt_dico){ @@ -60,7 +64,31 @@ void ini_dico(struct dico * pt_dico){
60 cons_dico(&pt_dico,97+i); 64 cons_dico(&pt_dico,97+i);
61 } 65 }
62 } 66 }
  67 +
  68 +
  69 +void ajout_mot(struct dico *pt_dico,char mot[]){
  70 + int i=0;
  71 + while(mot[i]!='\0'){
  72 + if (pt_dico->alpha[val[i]-'a']==NULL){
  73 + cons_arbre(&(pt_dico->alpha[mot[i]-'a']),mot[i]);
  74 +
  75 + }
  76 + i++;
  77 + }
  78 + pt_dico->alpha[fscval[i]-'a']->finmot=true;
63 79
  80 +}
  81 +
  82 +void charger_arbre(FILE *fp, struct dico **pt_dico)
  83 +{ char mot[20];
  84 + while (fscanf(fp, "%s", mot)!=EOF){
  85 + ajout_mot(*pt_dico,mot);
  86 +
  87 + // -------------------------------------------------------------
  88 + }
  89 + return ;
  90 + //Tip: use while(fscanf(..) ...)
  91 +}
64 92
65 93
66 94