This question already has an answer here:
I know that:
Foo *array[10]; // array of 10 Foo pointers
Foo (*array)[10]; // pointer to array of 10 Foos
However, I don't really understand the logic behind this notation. That is, why does the first part create an array of pointers why the second creates a pointer to an array?
Of course I can easily remember this notation, but I would like to know the logic behind it.
Foo* array[10]
so there is no confusion between that and the second line. It makes it clear that the type of the array isFoo*
. – 0x499602D2 Jun 28 '13 at 20:35int *(*(*(*b)())[10])();
:) Reading C declarations. – jrok Jun 28 '13 at 20:38Foo (*array)[10];
dererencing it (*array
) gives youFoo[10]
. Here's some reading on the matter. – jrok Jun 28 '13 at 20:43