How does the computer know when one row ends and another row begins in a 2d array? I have
int[2][2] = {{0, 1}, {2, 3}}
which saves into contiguous memory the values of 0, 1, 2, and 3. int[4] = {0, 1, 2, 3}
would save into memory the same values. How does the computer know to return a 2 for int[1][0]
. It would need to know the length of a column so that it can multiply 1*(column length of 2) + 0 to get the third element. I'm programming in cpp. Thanks.