Pase una matriz multidimensional a una función en C
Tengo una función como esta:
void myfunc(int** arr, int n) {
int i, j;
for(i=0; i<n; ++i) {
for(j=0; j<n; ++j) {
printf("%d,", *(arr + i*n + j) ); // Print numbers with commas
}
printf("\n"); // Just breakline
}
}
en otra función tengo una matriz bidimensional como esta:
int main() {
int seqs[8][8] = {
{0, 32, 36, 52, 48, 16, 20, 4},
{0, 16, 20, 52, 48, 32, 36, 4},
{0, 32, 36, 44, 40, 8, 12, 4},
{0, 8, 12, 44, 40, 32, 36, 4},
{0, 32, 36, 38, 34, 2, 6, 4},
{0, 2, 6, 38, 34, 32, 36, 4},
{0, 32, 36, 37, 33, 1, 5, 4},
{0, 1, 5, 37, 33, 32, 36, 4}
};
// Call to myfunc
myfunc(seqs, 8); // This is the idea
}
Pero el compilador me arroja este error:
lab.c: In function 'main':
lab.c:75:5: warning: passing argument 1 of 'myfunc' from incompatible pointer type [enabled by default]
lab.c:4:6: note: expected 'int **' but argument is of type 'int (*)[8]'
¿Cuál es la forma correcta de pasar esta matriz (seqs
) funcionar (myfunc
)?