The following code throws error !
Code:#include <stdio.h> int main(void) { int array[][]={{1,2,3},{123,244,232}}; }
This works fine!
Code:#include <stdio.h> int main(void) { int array[][3]={{1,2,3},{123,244,232}}; }
The following code throws error !
Code:#include <stdio.h> int main(void) { int array[][]={{1,2,3},{123,244,232}}; }
This works fine!
Code:#include <stdio.h> int main(void) { int array[][3]={{1,2,3},{123,244,232}}; }
Because only the leftmost index can be arbitrary, all other indices must have a fixed size. In other words, all 2D arrays in C must be rectangular, with the same amount of columns for every row.
Last edited by GReaper; 11-22-2017 at 08:51 AM.
Devoted my life to programming...
That is what is written in the book. There is a post on stack overflow about this. Here
Can you please explain it. I can't seem to understand the answer to the question in that post. Please
ans 20 explained it rather well.
In the example question you posted, the OP is asking about passing an array to a function. This is a little bit different than your plain array definition.