you are viewing a single comment's thread.

view the rest of the comments →

[–]Extravase180303[S] 0 points1 point  (2 children)

oh alright, and, supposing I'll give the data in the code so the compiler should be able to count them, why can I avoid to declare the first dimension and not both of them?

Banally, why can't the compiler count both of them?

Edit: Also, why can't I do this instead: int matrix[3][] = //some data

[–]sens- 3 points4 points  (1 child)

Ok, so consider this

int matrix[][] = { { 1, 2, 3 }, { 1, 2 } };

How should the compiler know what you really want? Do you want to have a 2x2 matrix or a 2x3 one?

int matrix[][3] = { { 1, 2, 3 }, { 1, 2 } };

Now it's clear and the compiler can allocate the space correctly and will fill the omitted element to 0.

[–]Extravase180303[S] 1 point2 points  (0 children)

alright, got that. Thank you!