HI,
I am trying to pass a multidimensional array to a function with the following code:
Code:
#include <stdio.h>
#include <stdlib.h>
void printSize (char x[][3][3]) {
printf("size of x: %d\n", sizeof(x)); //4, why???
return;
}
int main(int argc, char **argv)
{
int i,j,k;
char p[6][3][3];
for(i=0;i<6;i++) for(j=0;j<3;j++) for(k=0;k<3;k++) p[i][j][k] = (char)i;
printf("size of p: %d\n", sizeof(p)); //54, as expected
printSize(p);
return 0;
}
The code compiles without any errors or warnings, but when run the output is:
Code:
size of p: 54
size of x: 4
Can anyone tell me what is wrong with my code, and - more importantly - how to solve it?