Consider the following piece of code :
Code:
int s[4][2] = {
{1, 2},
{3, 4},
{5, 6},
{7, 8}
};
int * p;
int (*pp)[2];
for(int i = 0; i < 4; i++)
{
p = &s[i]; //incorrect
p = (int *)&s[i]; //alternative 1
pp = &s[i]; //alternative 2
}
I am aware of the fact that in C, multidimensional arrays are stored as array of arrays & so on. If the 2-D array is split into 4 single dimensional arrays (as in the above example) and &s[i] returns the address of each of these single dimensional arrays, why can't it be simply assigned to an integer pointer ? Also, exactly what is the implication of this syntax - int (*pp)[2] ?