05-02-2010, 08:36 PM
06-02-2010, 02:34 PM
Its very simple
C++ will calculate the 2D Array using following Formula in case of array[0][6]
array + 0*3 + 6
0 is required row and 6 is required column , 3 is total rows
As C++ store data in row major then in this case it will skip 6 memory locations and result will be 7
C++ will calculate the 2D Array using following Formula in case of array[0][6]
array + 0*3 + 6
0 is required row and 6 is required column , 3 is total rows
As C++ store data in row major then in this case it will skip 6 memory locations and result will be 7
10-06-2010, 11:06 AM
It is absolutely out of bound but in the memory of the 7th place form the variable array must have some value. Weather it is garbage value but something is stored there, thats why it gives you the answer. It is a garbage value.