The two declarations are as follows:
int (*p)[8];
int *p[8];
The first is a single pointer to an array of 8 integers, while the second is an array of 8 pointers, each to an integer.
If you just kick up cdecl
, it's wonderful for this sort of thing:
pax$ cdecl
Type `help' or `?' for help
cdecl> explain int (*p)[8];
declare p as pointer to array 8 of int
cdecl> explain int *p[8];
declare p as array 8 of pointer to int
cdecl> explain char*(*fp[])(int,float*);
declare fp as array of pointer to function (int, pointer to float)
returning pointer to char
There's actually a clockwise/spiral rule you can use to do this in your head but I haven't had to worry about that since I discovered cdecl
, for the same reason I no longer convert large arbitrary 32 bit numbers from decimal to hex in my head any more - I can if I have to but it's so much easier with a tool :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With