For a pointer to an [2][2] char array, I can write: char (*p)[2][2] and
for an array of 10 elements of type pointer to char: char* p[10].
How do you write an array of 10 elements of type pointer to char[2][2]?
Why does this statement have a syntax error?
char (*)[2][2] p[10];
You need to use
char (*p[10])[2][2];
But you should really use a typedef, as these decl. can become exceedingly complicated:
typedef char (*ptr_arr)[2][2]; // our pointer-to-char[2][2]
ptr_arr p[10]; // now we have a clean syntax, this is an array of pointers to char[2][2]
You can also use the new using in C++11 like
using ptr_arr = char(*)[2][2];
ptr_arr p[10];
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