In C and C++, arrays are stored in memory by row. That is, all the columns of the first row appear first, then all the columns of the second row, etc. If you have an int array with 2 rows and 5 columns then the location of any given row can be caluculated by this formula
int *p = array + ((row_numer-1) * NumColumns)
int array[2][5];
// set a pointer at the beginning of row 2
int* ptr = (int*)array + (1*5);
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Offline 21,953 posts
since Aug 2005