ecriture dans un fichier texte
Bonjour à tous,
je possede une table de hachage que j'ai rempli avec des mots du texte.
J'aime bien mettre le contenu de la table de hachage dans un fichier texte, mais le fichier ne se produit pas :(
des idées svp pour souci
Merci
voila les fonctions :
Code:
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
| int EnregistrerDoubleTableFichTexte(TableHachageMot const DblTableHash[], char const *langue)
{
int retour = -1;
char nomFich[FILENAME_MAX];
FILE *pfOut;
if(snprintf(nomFich, ARRAYSIZE(nomFich), ".\\%s_Table%d.txt", langue, 1) >= ARRAYSIZE(nomFich))
{
errno = E2BIG;
return -1;
}
pfOut = fopen(nomFich, "w");
if(pfOut != NULL)
{
dump_double_table(pfOut, DblTableHash);
retour = 0;
fclose(pfOut);
}
return retour;
} |
la fonction dump-double_table:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| void dump_double_table(FILE* pfOut, TableHachageMot const DblTableHash[])
{
size_t boucle;
for ( boucle = 0; boucle != TAILLEHASH; boucle++)
{
fprintf(pfOut, "prefixhash=%d\n", boucle);
dump_table(pfOut, DblTableHash[boucle]);
}
fputc('\n', pfOut);
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| void dump_table(FILE* pfOut, ListeMot const TableHash[])
{
size_t boucle;
for ( boucle = 0; boucle != TAILLEHASH; boucle++)
{
if (!ListeEstVide(&TableHash[boucle]))
{
AfficherListe(pfOut, &TableHash[boucle]);
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| void AfficherListe(FILE *pfOut, ListeMot const *L)
{
/*assert(L!=NULL);*/
ChainonMot const *pc;
for (pc = GetPremierC(L) ; pc!=NULL ; pc=GetNextC(pc))
{
fprintf(pfOut, "\t(\"%s\", %d lignes", GetMot(pc), GetNbLignes(pc));
fprintf(pfOut, ")\n");
}
} |