plz give me links or discuss on address calculation in 2d arrays.
i have little knowledge of calculating the address. can any one give some formula or something coz my professor gave it but i wasnt able to follow . i remember he was using terms like rowmajor, column major, lower base , upper base etc.
so if any one is having knowledge plz help as this topic is not even in the book that i am using ( the course book i mean).

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.