Possible Duplicates:
Passing multidimensional arrays as function arguments in C Converting multidimensional arrays to pointers in c++
Hi,
I try to pass 2 dimension arrays to function in C, and the following co开发者_开发知识库de works
void printArray(int a[][4], int size) {
int i = 0;
for (; i < size; ++i) {
int j = 0;
for (; j < size; ++j) {
printf("%d,", a[i][j]);
}
printf("\n");
}
}
but if I replace "int a[][4]"
to "int **a"
it won't work, can anyone tell what's the difference ?
Thanks
Obligatory link: http://c-faq.com/aryptr/pass2dary.html. Everything you need to know should be in there; I won't bother writing it all out here...
精彩评论