when trying to initialize a multidimensional array like this:
int a[][] = { {1,2,3},
{4,5,6} };
I get this error:
error: declaration of iArray as multidimensional array must have bounds for all dimensions except the first
but I want to understand why, the compiler should know it's a[2][3] array because of the {}.
I know that is allowed also to do:
int a[][3] = {1,2,3,4,5,6};
and for that case indeed the compiler can't guess what is the 2nd dimension if it missing, but why not to allow the use of a[][] in the first case?
[Shrug] That's just the way it is.
You could propose changing the standard to allow this. You would need to:
It's not obvious to me that this would have many gotcha's, but on the other hand, it's also not obvious how much of a benefit it would be (adding extra support for raw arrays is probably pretty low on everyone's mind).
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