Bonjour,
Comme le précise le titre je veux faire une allocation mémoire de int* mat[3] et non pas int** mat puis je dois passer la matrice comme paramètre à la fonction (Assign_V1()).
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 void Assign_V1(int* mat[3], int N, int M) { for(int i=0; i<N; i++) for(int j=0; j<M; j++) mat[i][j]=i+j; } int main() { const int N=4; const int M=3; //je dois avoir une matrice mat[4][3] int (*mat)[3] = malloc(N * sizeof(*mat)); //***Mon problème Assign_V1(mat, N, M); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { printf("%3d", mat[i][j]); } printf("\n"); } return 0; }
Par avance merci.
Partager