I'm reading a book on C and I stumbled upon the following piece of code with advanced pointer use:
Code:
int main()
{
float (*a)[5];
int n=3, i, j;
a = (float(*)[5])malloc(n*sizeof(float[5]));
for(i=0; i < n; i++)
for(j=0; j < 5; j++) a[i][j] = ...
According to the book *a is an array of 5 float elements so a is a pointer to an array of 5 float elements. Also, the book says that the n rows are in a sequence. The last remark I can understand, because malloc allocates n*5 float elements. I just don't understand why a is a pointer to an array of 5 float elements. I would think it is an array to n*5 elements. Does anybody see what I'm overlooking here?