As I see it int *x[n][m]
declares x
to be a 2-d array of pointers to integers, so allocating memory should be as easy as x[i][j] = new int
and as expected it works fine. Now if I change the declaration to:
int (*x)[n][m]
x[i][j] = new int
no longer works and results in a compilation error.
x = (int(*)[n][m]) malloc (sizeof(int[n][m]))
however compiles. From the few tests I ran, after the memory allocation, the different declaration/allocation combination doesn't seem to effect the values stored in the variable. Am I missing something? So my question is, **Is there a difference between int *x[n][m] and int (x)[m][n]. How is int (x)[n][m] stored in memory?