From 2e977567d8f67d591b90f200a629eb550c20bd61 Mon Sep 17 00:00:00 2001 From: rsSimonin Date: Thu, 28 Mar 2019 12:10:43 +0100 Subject: [PATCH] 2 commit --- arbre.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/arbre.c b/arbre.c index 760302c..5b27704 100644 --- a/arbre.c +++ b/arbre.c @@ -49,8 +49,12 @@ void cons_dico(struct dico **pt_dico,char val){ void cons_arbre(struct arbre **pt_arbre,char val){ struct arbre *monarbre=malloc(sizeof(struct arbre)); - monarbre->suite[val-97]->val=val; // (ascii)->a = 97 - + monarbre->val=val; // (ascii)->a = 97 + for(int i=0;i<26;i++){ + monarbre->suite[i]=NULL; + } + monarbre->finmot=false; + (*pt_arbre)=monarbre; } @@ -60,7 +64,31 @@ void ini_dico(struct dico * pt_dico){ cons_dico(&pt_dico,97+i); } } + + +void ajout_mot(struct dico *pt_dico,char mot[]){ + int i=0; + while(mot[i]!='\0'){ + if (pt_dico->alpha[val[i]-'a']==NULL){ + cons_arbre(&(pt_dico->alpha[mot[i]-'a']),mot[i]); + + } + i++; + } + pt_dico->alpha[fscval[i]-'a']->finmot=true; +} + +void charger_arbre(FILE *fp, struct dico **pt_dico) +{ char mot[20]; + while (fscanf(fp, "%s", mot)!=EOF){ + ajout_mot(*pt_dico,mot); + + // ------------------------------------------------------------- + } + return ; + //Tip: use while(fscanf(..) ...) +} -- libgit2 0.21.2