+ 1
2D array
Why do we need to specify the column of the two dimensional array while we can leave the row unspecified?
2 Answers
0
You can't, as far as I'm concerned. Can you show me an example of what you are referring to?
0
If the length of rows (no. of columns) is not specified, the compiler can't determine where exactly the next row is going to begin.
ex: int Arr[2] [3]
which is nothing but array having two 1-D arrays of 3 elements each
if you decide to pass this array as an argument to any function you can skip left most dimension.
This is applicable to all multi dimensional arrays. You must specify all but the left most dimension.
ex: int Arr[] [3] [4]
why can you leave row unspecified?
just passing array name to function returns pointer to the first element of the array, from there you can traverse through the 2-D array if you know number of columns in the array. Hence it's optional to specify row dimension.