What is the difference between
int * a[10];
and
int (*b)[10];
I know that the first one is an array of pointers to integers, but what is the second one? If I try assigning
int (*c)[10] = a;
what am I actually doing to c?
See if you can install the cdecl
command for your system. (On Ubuntu, sudo apt-get install cdecl
.) There's also a web interface at cdecl.org.
Here's what it told me for your examples on my system:
$ cdecl
Type `help' or `?' for help
cdecl> explain int * a[10];
declare a as array 10 of pointer to int
cdecl> explain int (*b)[10];
declare b as pointer to array 10 of int
cdecl>
Second one is a pointer to an array of 10 integers. Where? God knows; you never initialized it.
If you assign a
to it, you're making it point to the same array of 10 integers that a
pointed to... nothing fancy.
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