What is the difference between
char *a[10];
and
char *(a[10]);
I’ve always used the first for an array of char pointers, but now I’ve found code used the second.
As I was not sure if it was the same thing, I printed sizeof() both and both return 80 (64bit OS) so I’m inclined to believe both are the same (an array of char pointers).
But as I cannot find any explanation online or anything using *([]) syntax, I was looking for some confirmation.
Thanks
The two are equivalent and stand for a 10-element array of pointers to
char.Contrast with
char (*a)[10], which is a pointer to a 10-element array ofchar.If in doubt, one could use
cdeclto unscramble C declarations. On Unix it’s usually available as a command-line tool. There’s also an online version.