Bonjour bonjour,

Voila jai un tableau nommé matricegroupegeneralisant de type [2][][].
Je souhaiterais le passer en paramètre pour faire une allocation dynamique.

fonction qui pose probleme : allocmatrices
utilisation ligne 78
declaration ligne 161

lerreur de compilation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
test.c: In function ‘generalisationAttribut’:
test.c:78:2: warning: passing argument 3 of ‘allocmatrices’ from incompatible pointer type [enabled by default]
test.c:12:6: note: expected ‘int ***’ but argument is of type ‘int ** (*)[2]’
a: 0 b: 1
type de gen : 1
fichier de generalisation utilisee : genO.txt
 nbgroupegeneralisant :3
5 5 5 5 5 
5 5 5 5 5 
5 5 5 5 5 
5 5 5 5 5 
Error: the input file was not found!
Error: the input file was not found!
larimsna1@larimsna1:~/Desktop/corontest17/gen$
Voici 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Nmcl 200 //nombre maxi de caractere pour ligne attribut ou objet 
#define Nmcm 20  //nombre maxi de caractere pour un mot
#define nbligneenteteGpar1 4
#define nbligneenteteGenU 2
 
void ouvrir_fic(FILE**, char*, char*);
int determinationtypedegenchoisi(FILE* fichG);
int** generalisationAttribut(char* nomfichierdegen, int nbligneMat,int nbcolonneMat);
void allocmatrices(int*** Matrice,int** nbelementpargroupe, int** matricegroupegeneralisant [2],int nbgroupegeneralisant, int nbligneMat, int nbcolonneMat);
void allocationdynamiquetableauunedimdentier(int** nbelementpargroupe, int nbgroupegeneralisant);
void allocationdynamiquetableaudeuxdimdentier(int*** Matrice, int nbligne, int nbcolonne);
void affichageMatrice(int departligne, int nbligne, int departcolonne, int nbcolonne, int** Matrice);
int comptagenbgroupegeneralisant(FILE* fichTmp);
 
 
void main(int args, char **argv)
{
	FILE * fichG=NULL; // fichier de presentation des generalisations
	int** Matrice; // le contexte
 
	int typedegen; //generalisation sur objet, sur attribut ou sur objet et attribut
	char NomUniqueFichierGen[Nmcm];
	char NomFichierGenA[Nmcm];
	char NomFichierGenO[Nmcm];
	int i;
	char chaine[Nmcl];
 
	ouvrir_fic(&fichG, argv[2],"r");
	typedegen=determinationtypedegenchoisi(fichG);
	printf("type de gen : %d\n",typedegen);
 
	for(i=0;i<nbligneenteteGpar1;i++)       // on saute les lignes de commentaires
	{
		fgets(chaine, sizeof chaine, fichG);
	}
 
	if(typedegen==0 || typedegen==1) // si qu'un seul fichier de generalisation
	{
		fscanf(fichG,"%s",NomUniqueFichierGen);
		printf("fichier de generalisation utilisee : %s\n ",NomUniqueFichierGen);
	}
 
 
	Matrice=generalisationAttribut(NomUniqueFichierGen,4,5);
 
 
 
	affichageMatrice(0,4,0,5, Matrice);
}
 
 
 
 
 
int** generalisationAttribut(char* nomfichierdegen, int nbligneMat,int nbcolonneMat)
{
	int* nbelementpargroupe; // nombre delement par groupe
	int** Matrice; // le contexte
	int** MatriceTransposee; // contexte transpose
	int** Matricegenere;  // contexte de base+contexte genere
	int** matricegroupegeneralisant [2]; // matrice de generalisation
	int** groupegeneralisant [2]; // matrice de generalisation reduite
	int i,j;
	FILE * fichU=NULL;
	FILE * fichTmp=NULL;
	int nbgroupegeneralisant;
 
	ouvrir_fic(&fichTmp, nomfichierdegen,"r");
	nbgroupegeneralisant=comptagenbgroupegeneralisant(fichTmp);
	printf("nbgroupegeneralisant :%d\n",nbgroupegeneralisant);
	fclose(fichTmp);	
 
	/// allocation dynamique des matrices
	//allocmatrices();
	allocmatrices(&Matrice,&nbelementpargroupe,&matricegroupegeneralisant,nbgroupegeneralisant,nbligneMat,nbcolonneMat);
 
	allocationdynamiquetableaudeuxdimdentier(&Matricegenere,nbligneMat,nbcolonneMat+nbgroupegeneralisant);
 
	/*allocationdynamiquetableaudeuxdimdentier(&matricegroupegeneralisant[0],nbgroupegeneralisant,nbligneMat);
	allocationdynamiquetableaudeuxdimdentier(&matricegroupegeneralisant[1],nbgroupegeneralisant,nbcolonneMat);*/
 
	allocationdynamiquetableaudeuxdimdentier(&groupegeneralisant [0],nbligneMat,nbcolonneMat);
	allocationdynamiquetableaudeuxdimdentier(&groupegeneralisant [1],nbligneMat,nbcolonneMat);
	for(i=0; i<nbligneMat;i++)
	{
		for(j=0; j<nbcolonneMat;j++)
		{
			Matrice[i][j]=5;
		}
	}
 
	return(Matrice);
}
 
void ouvrir_fic(FILE** f, char* nom,char* type)
{ 
*f=fopen(nom,type); 
}	
 
int determinationtypedegenchoisi(FILE* fichG)
{
	int c,a,b,typedegen;
	c = fgetc(fichG);       // premiere parenthese
	fscanf(fichG, "%d",&a); // premier chiffre
	c = fgetc(fichG);	// virgule
	fscanf(fichG, "%d",&b);	// second chiffre
	c = fgetc(fichG);	// seconde parenthese
	c = fgetc(fichG); 	// marqueur fin de ligne
	printf("a: %d b: %d\n",a,b);
 
	if(a==1)
	{
		if(b==0)
		{
			typedegen=0;
		}
		else
		{
			typedegen=2;
		}
	}
	else
	{
		if(a==0 && b==1)
		{
			typedegen=1;
		}
		else
		{
			printf("pas de generalisation demandee\n");
			exit(2);
		}
	}
	return(typedegen);
}
 
int comptagenbgroupegeneralisant(FILE* f)
{
	int nb_ligne=0,c;
	if (f == NULL)
	{
		printf("erreur lecture fichier pour comptagenbgroupegeneralisant\n");
	}
	else
	{
		while((c = fgetc(f)) != EOF)          //compteur de ligne
		{
			if(c == '\n')
			{
				nb_ligne++;
			}
		}
		return(nb_ligne-nbligneenteteGenU); 
	}
}
 
 
void allocmatrices(int*** Matrice,int** nbelementpargroupe, int** matricegroupegeneralisant [2],int nbgroupegeneralisant, int nbligneMat, int nbcolonneMat)
{
	//allocationdynamiquetableauunedimdentier(nbelementpargroupe, nbgroupegeneralisant);
	allocationdynamiquetableaudeuxdimdentier(Matrice,nbligneMat,nbcolonneMat);
}	
 
void allocationdynamiquetableauunedimdentier(int** nbelementpargroupe, int nbgroupegeneralisant)
{
	*nbelementpargroupe=(int*) malloc (sizeof(int)*nbgroupegeneralisant); 
}
 
 
void allocationdynamiquetableaudeuxdimdentier(int*** Matrice, int nbligne, int nbcolonne)
{
	int i,j;
	*Matrice=(int**) malloc (sizeof(int*)*nbligne);  // allocation dynamique de la matrice Matrice
	for (i=0; i<nbligne; i++)
	{
		(*(Matrice))[i]=(int*) malloc (sizeof(int)*nbcolonne);
	} 
}
 
void affichageMatrice(int departligne, int nbligne, int departcolonne, int nbcolonne, int** Matrice)
{
	int i,j;
	for(i=departligne; i<nbligne;i++)
	{
		for(j=departcolonne; j<nbcolonne;j++)
		{
			printf("%d ",Matrice[i][j]);
		}
		printf("\n");
	}
}
Merci beaucoup !!!