bonjour à tout le monde.
Description du programme : le but est de réaliser un programme qui permet de traduire des mots ou/et des phrases à partir d´un fichier dans une table de hachage
Ce qui cloche, c´est la fonction sauverH qui permet d´extraire les mots en français et en anglais du fichier et de les sauver dans la table de hachage.
Le problème est que quand je fait appel à cette fonction dans le main, tout au début pour bien que la table se charge, mon compilateur me donne un cadre tout en noir. Et si je la supprime ça va, le menu s'affiche pourtant je ne peux rien traduire à partir de la table car elle n´est pas encore remplie par la fonction sauverH.
Alors si quelqu'un pouvait me trouver d'où viendrait l'erreur ? Avec tous mes respects pour tous les développeurs.

Voici tout mon programme :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
 
typedef struct traduction
{
        char *fr;
        char *eng;
        }traduction;
typedef struct table 
{
        int nmax;
        int n;
        taduction ** element;
}table;
 
table * creertabe(int nmax)
{
 
     table *tab=(table*)malloc(sizeof(table));
      tab->nmax=nmax;
      tab->n=0;
      tab->element=(traduction**)malloc(sizeof(traduction*)*nmax);
     // for(i=0;i<tab->nMax;i++)
     // tab->element[i]=NULL;
      return tab;
 
}
 
 
// déclaration de la fonction de hachage//
 int H (char* cle,int N)
 {
     int i,som=0;
     for(i=0;i<strlen(cle);i++)
     {
                               som+=cle[i];
     }
   return som % N ; 
 }
 
 void sauverH(table *tab,char *f)
 {
      FILE *monfichier = fopen(f,"a+");
      int i=0;hr=1;h;
      char *F;char *A;
       while(!feof(myfile)) {
      h=H(F,tab->nmax);
      if (tab->element[h]=NULL) 
      {
            strcpy(tab->element[h]->fr,F);
            strcpy(tab->element[h]->eng,A);
            }
            else {
                 //resoudre probleme de collision
                 while (tab->element[hr]!=NULL && (i<tab->nmax) )
                 {
                       hr=(h+i)%tab->nmax;
                       i++;
                       }
                       if (tab->element[hr]=NULL)
                       {
                        strcpy(tab->element[hr]->fr,F);
                        strcpy(tab->element[hr]->eng,A);
                        }
                   }
 
                   }
                   fclose(monfichier);
                   }
 
 
 //insertion d´un nouveau mot 
void insertable(table`*tab, char *f)
{
     FILE *monfichier = open(f,"a+");
     int h,hr,i=0;
     char *F; char *A;
     printf("Donner le nouveu mot que vous voulez ajouté en francais");
     gets(F);
     h=H(F,tab->nmax);
     if(tab->element[h]=NULL) 
     {
                              strcpy(tab->element[h]->fr,F);
                              printf("Donner son equivalent en anglais");
                              gets(A);
                              strcpy(tab->element[h]->eng,A);
                              fprintf(monfichier,"%s %s\n",tab->element[h]->fr,tab->element[h]->eng);
                              }
                              else {
                                   //resolution de probleme de collision
                                   while(tab->element[hr]!=NULL && i<tab->nmax)
                                   {
                                                               hr=(h+i)*tab->nmax;
                                                               i++;
                                                               }
                                                               if (tab->element[hr]=NULL)
                                                               {
                                                                                         strcpy(tab->element[hr]->fr,F);
                                                                                         printf("Donnner son equivalent en anglais");
                                                                                         gets(A);
                                                                                         fprintf(monfichier," %s %s",tab->element[hr]->fr,tab->element[hr]->eng);
                                                               }
                                                               else {
                                                                    printf("Désolé le tableau est plein!!!!");
                                                                    }
     fclose(monfichier);
     }
     //traduction un mot
 
     void tradMot(table *tab,char *F)
	{
	 char* A;
	 int x=1,i=1,hr=0,h;
 
			   h=H(F,tab->nMax);
			  if(tab->element[h]==NULL)
				 {
				 printf("ce mot n'existe pas dans ce petit dectionnaire\n");
				  }
 
			  else
				{
				   while((tab->element[hr]!=NULL)&&(i<tab->nMax))
					  {
					   if(strcmpi(tab->element[hr]->fr,F)==0)
						 {
							 puts(tab->element[hr]->eng);
							 x=0;
							 break;
						  }
 
						   hr=(h+i)%tab->nMax;
						   i++;
					   }
						 if(x==1)
						 printf("ce mot n'existe pas dans ce petit dectionnaire\n");
 
					}
 
 
   }
 
 
 
 
 
 /*
void charger (table *tab, char *f)
{
     traduction *trd;
     while(! feof(f))
     {
            traduction *trd = new traduction();
             fscanf(fichier,"%s %s ",trd->fr,trd->eng);  
             insertable(tab,trd);
             delete(trd);
     }
 }
 
bool insertable(table *tab, traduction *trd)
 {
         if (table->n < table->nmax )
         {
                      table->element[table->n+1]=trd;
                      return   vrai;
         }
                      else return faux;
 }
 
traduction* traduire (table *tab,traduction *trd, char[] *mot)
{    
     int i=0; bool trouve=faux;
     while (i<tab->n && !trouve) 
     {
           trouve= comparer(tab->trd[i]->fr,mot);
           if (!trouve) i++;
     } 
       return trouve ? tab->trd[i]->eng : NULL
}   
 
int comparer(int x,int y)
{
     if (x!==y) return 0;
     else return 1;
}
*/
 
void menu()
{
     printf("0-FIN.\t\t");
     printf("1-Inserer dans la table.\n\n");
     printf("2-Traduire un mot.\n\n");
     print("3-Traduction d´une phrase.\n\n");
     print("Entrer votre choix");
}
 
 
void main()
{
     table tab1 = creertabe(100);
     char* mot;
     int choix;
     sauverH(tabl,"hello.txt");
     clrscr();
     menu();
     choix=getch();
     do 
     {
        switch(choix)
                     {
                         case '0': exit(0); 
                            break();
 
                         case '1':  
                                    insertable(tab1,"hello.txt");
                                   printf("votre nouveau mot a été ajouté avec succés dans le dictionnaire!");
                                    getch();
                                    clrscr();
                                    menu();
                                    break;
 
 
                         case '2': 
                                   printf("Entrer le mot en francais que vous voulez traduire!");
                                   gets(mot);
                                   printf("son ‚quivalent en anglais est:\n");
                                   tradMot(tab1,"hello.txt");
                                   getch();
                                   clrscr();
                                   menu();
                                   break;
 
                         case '3':
                                  getch();
                                  clrscr();
                                  menu();
                                  break; 
 
 
 
                         default : 
                           printf("Vous avez pas sasie le bon numero dans le menu");
                           clrscr();
                            menu();
                 } while (1);
 
}
PS : en fait le fichier hello.txt c'est le fichier utilisé.


Merci !!!!