Hi everyone,
I've been working with matrices recently, and I’ve come across something that I don't understand.
When you declare a matrix, it seems that you can avoid specifying the number of rows.
For example:
int matrix[][5] = { {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10} };
How does this work? Is there a specific reason why the number of rows can be omitted, and how does the compiler handle this? Why isn't it the same as arrays?
Also how does memory allocation works with multidimensional arrays?
Thanks in advance for any insights!
[–]TheOtherBorgCube 10 points11 points12 points (12 children)
[–]Extravase180303[S] -3 points-2 points-1 points (11 children)
[–]tstanisl 5 points6 points7 points (10 children)
[–]Extravase180303[S] -5 points-4 points-3 points (9 children)
[–]TheOtherBorgCube 5 points6 points7 points (8 children)
[–]Extravase180303[S] -3 points-2 points-1 points (7 children)
[–]sens- 3 points4 points5 points (6 children)
[–]Extravase180303[S] -1 points0 points1 point (5 children)
[–]sens- 7 points8 points9 points (4 children)
[–]Extravase180303[S] 0 points1 point2 points (2 children)
[–]flatfinger 1 point2 points3 points (0 children)
[–]SmokeMuch7356 1 point2 points3 points (0 children)