bonjour à tous,
j'ai crée une fonction qui remplit une table de hachage et qui retourne une table de hachage rempli.
le probleme c'est qu'il maffiche une erreur :`LireFichierEntree' declared as function returning an array|
je vois pas la cause du probleme
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
TableHachageMot LireFichierEntree(char const *langue, TableHachageMot DblTableHash[], int *pNbLignes)
{
	int retour = -1;
	FILE *fdesc = NULL;
	if(pNbLignes != NULL)
		*pNbLignes = 0;
	fdesc = ouvrir_fichier_entree(langue);
	if ( fdesc==NULL )
	{
		perror("fopen");
	}
	else
	{
		char* buff = NULL;
		char* prec = NULL;
		char* concat = NULL;
		size_t tailleBuff = 0;
		size_t taillePrec = 0;
		size_t tailleConcat = 0;
		int ancienneLigne = -1;
		int ancienneColonne = -1;
		int ligne = 0;
		int colonne = -1;
		ssize_t res;
 
		printf("Lecture du fichier texte (prog: 1 point pour %d lignes)...\n", PROG_NBLIGNES);
		while ( (res=get_word(fdesc, &buff, &tailleBuff, &ligne, &colonne))>0 )
		{
			if(ancienneLigne == ligne)
			{
				static char const separ[] = {SEPARATEUR, '\0'};
 
				/* Mot sur la même ligne: Ajouter 2seq */
				if(tailleConcat < 2*tailleBuff)
				{
					tailleConcat = 2*tailleBuff;
					ReallocCharExit(&concat, tailleConcat);
				}
				assert(concat != NULL);
 
				strcpyN(concat, tailleConcat, prec);
				strcatN(concat, tailleConcat, separ);
				strcatN(concat, tailleConcat, buff);
 
				#if 0
				AfficherEspaces(ancienneColonne);
				puts(concat);
				#endif
				InsertionDoubleHashEx(DblTableHash, concat, ancienneLigne, ancienneColonne);
			}
			else
			{
				if(ligne%PROG_NBLIGNES==0)
					putchar('.');
			}
 
			/* Mémorise l'ancien mot et son n° de ligne */
			ancienneLigne = ligne;
			ancienneColonne = colonne;
			/* Pour de meilleures performances,
			  on bosse en double buffer plutot que recopier à chaque fois.*/
			if(taillePrec != tailleBuff)
			{
				taillePrec = tailleBuff;
				ReallocCharExit(&prec, taillePrec);
			}
			assert(prec != NULL);
			assert(taillePrec == tailleBuff);
			SwapPtrChar(&prec, &buff);
		}/*while*/
 
		if(res < 0)
			perror("get_word");
		else
		{
			retour = 0; /* OK */
			putchar('\n');
			printf("Lu %d lignes.\n", ligne);
			if(pNbLignes != NULL)
				*pNbLignes = ligne;
		}
 
		/* Nettoyage */
		free(concat), concat=NULL, tailleConcat=0;
		free(prec), prec=NULL, taillePrec=0;
		free(buff), buff=NULL, tailleBuff=0;
		fclose(fdesc), fdesc=NULL;
	}/*if fdesc*/
	return DblTableHash;
}