diff --git a/find.c b/find.c index ccdc9df..6b60c93 100644 --- a/find.c +++ b/find.c @@ -22,7 +22,7 @@ int find_mot(struct node **tab_ptr_tree,char mot[],int size,int fl) ptr_node=ptr_node->fils[k]; break; } - if(k+1==ptr_node->nbr_fils)return 1; + else if(k+1==ptr_node->nbr_fils)return 1; } } diff --git a/main.c b/main.c index ea96980..aa5451d 100644 --- a/main.c +++ b/main.c @@ -2,8 +2,8 @@ int main() { - //FILE* fp = fopen("american-english","r"); - FILE* fp = fopen("dico_test","r"); + FILE* fp = fopen("american-english","r"); + //FILE* fp = fopen("dico_test","r"); if(fp == NULL) return 1 ; //File is not readable @@ -18,8 +18,12 @@ int main() printf("Loading done!\n"); - char mot[] = "aaa"; - int taille = 3; + char mot[50];// = "aardvark"; + int taille; + //mot = "arabesque"; + taille = 8; + scanf("%s",mot); + scanf("%d",&taille); int result; result = find_mot(tab,mot,taille,0); printf("%d\n",result); diff --git a/tree.c b/tree.c index 590adcc..9eafce6 100644 --- a/tree.c +++ b/tree.c @@ -37,7 +37,7 @@ void add(struct node **tab_ptr_tree, char val[],int taille, int fl) noeudtest->nbr_fils++; noeudtest->fils = realloc(noeudtest->fils,(noeudtest->nbr_fils)*sizeof(struct node*)); cons_tree(&(noeudtest->fils[(noeudtest->nbr_fils)-1]),val[i]); - trouve = 0; + trouve = noeudtest->nbr_fils-1; } noeudtest = noeudtest->fils[trouve];//on jump au noeud suivant @@ -56,6 +56,17 @@ int size(char val[]) return cpt; } +void toLowerCase(char mot[],int size) +{ + for(int i=0;i='A') + { + mot[i]+=32; + } + } +} + void load_tree(FILE *fp, struct node **tab_ptr_tree) { @@ -65,6 +76,7 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree) while(fscanf(fp, "%s",val)==1) { int taille = size(val); + //toLowerCase(val,taille); if(val[0]<97)val[0]+=32; val[0]-=97; add(tab_ptr_tree,val,taille,(int)val[0]); -- libgit2 0.21.2