Last time we had a test in programming and one of the questions was the difference between initializing
int *x[10];
and
int (*x)[10];
Can anyone clarify this for me?
Last time we had a test in programming and one of the questions was the difference between initializing
int *x[10];
and
int (*x)[10];
Can anyone clarify this for me?
Type *x[10];
defines x as an array of 10 pointers to Type. So x itself is an array that contains pointers to Type. On the other hand,
Type (*x)[10];
defines x as a pointer to array-10 of Type. Hence x points to the befinning of an array of size 10, and the array contains objects of type Type. See this for a great introduction to how to read complicated declarations in C, and also try cdecl.org.