Commit aeb78bdf83f63b0662908bbe8861d4d19e391e3f
1 parent
86fcc45a
correction fin de mot
Showing
3 changed files
with
22 additions
and
6 deletions
Show diff stats
... | ... | @@ -2,8 +2,8 @@ |
2 | 2 | |
3 | 3 | int main() |
4 | 4 | { |
5 | - //FILE* fp = fopen("american-english","r"); | |
6 | - FILE* fp = fopen("dico_test","r"); | |
5 | + FILE* fp = fopen("american-english","r"); | |
6 | + //FILE* fp = fopen("dico_test","r"); | |
7 | 7 | |
8 | 8 | if(fp == NULL) return 1 ; //File is not readable |
9 | 9 | |
... | ... | @@ -18,8 +18,12 @@ int main() |
18 | 18 | |
19 | 19 | printf("Loading done!\n"); |
20 | 20 | |
21 | - char mot[] = "aaa"; | |
22 | - int taille = 3; | |
21 | + char mot[50];// = "aardvark"; | |
22 | + int taille; | |
23 | + //mot = "arabesque"; | |
24 | + taille = 8; | |
25 | + scanf("%s",mot); | |
26 | + scanf("%d",&taille); | |
23 | 27 | int result; |
24 | 28 | result = find_mot(tab,mot,taille,0); |
25 | 29 | printf("%d\n",result); | ... | ... |
... | ... | @@ -37,7 +37,7 @@ void add(struct node **tab_ptr_tree, char val[],int taille, int fl) |
37 | 37 | noeudtest->nbr_fils++; |
38 | 38 | noeudtest->fils = realloc(noeudtest->fils,(noeudtest->nbr_fils)*sizeof(struct node*)); |
39 | 39 | cons_tree(&(noeudtest->fils[(noeudtest->nbr_fils)-1]),val[i]); |
40 | - trouve = 0; | |
40 | + trouve = noeudtest->nbr_fils-1; | |
41 | 41 | } |
42 | 42 | |
43 | 43 | noeudtest = noeudtest->fils[trouve];//on jump au noeud suivant |
... | ... | @@ -56,6 +56,17 @@ int size(char val[]) |
56 | 56 | return cpt; |
57 | 57 | } |
58 | 58 | |
59 | +void toLowerCase(char mot[],int size) | |
60 | +{ | |
61 | + for(int i=0;i<size;i++) | |
62 | + { | |
63 | + if(mot[i]<='Z' && mot[i]>='A') | |
64 | + { | |
65 | + mot[i]+=32; | |
66 | + } | |
67 | + } | |
68 | +} | |
69 | + | |
59 | 70 | |
60 | 71 | void load_tree(FILE *fp, struct node **tab_ptr_tree) |
61 | 72 | { |
... | ... | @@ -65,6 +76,7 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree) |
65 | 76 | while(fscanf(fp, "%s",val)==1) |
66 | 77 | { |
67 | 78 | int taille = size(val); |
79 | + //toLowerCase(val,taille); | |
68 | 80 | if(val[0]<97)val[0]+=32; |
69 | 81 | val[0]-=97; |
70 | 82 | add(tab_ptr_tree,val,taille,(int)val[0]); | ... | ... |