Mathematically speaking, there is little to no difference between the two. You can use a mathematical expression to index into the 1D array as if it were 2D. In fact, there is no such thing as a 2D array - your compiler converts 2D arrays into 1D arrays and does the math for you.
In fact, there is no such thing as a 2D array - your compiler converts 2D arrays into 1D arrays and does the math for you.
Eh? Maybe some compilers might optimize it into a 1D array with optimizations enabled, but the traditional implementation involves an array of pointers, with each pointer pointing to an array of the desired element.
Whoops. Needless to say, I haven't touched this stuff in a while.
Eh? Maybe some compilers might optimize it into a 1D array with optimizations enabled, but the traditional implementation involves an array of pointers, with each pointer pointing to an array of the desired element.
No ma'am. An array of arrays is very different from an array of pointers to arrays.
Arrays guarantee that items are stored consecutively. LB is correct... if you have a 'natural' 2D array (as in... int x[5][5];, then all elements are crammed together consecutively just as they would be in a 1D array.