Pointer to Multidimensional Arrays:


Pointer to Multidimensional Arrays:

Pointers and two-dimensional arrays. We can access each element in a two-dimensional array with two subscribers where the first subscript is the row number and the second the column number. The notation of the pointer can also access the 2-D array elements. If arr is a 2-D array, any array member can be accessed with *(*(arr + i)+j) *(*) [j].

The 2-D array cannot be stored in lines and columns, as memory is structured in a computer linearly. The concept of rows and columns is theoretical only; in fact, a 2-D array is stored in row-bigger order, i.e. rows are stacked side by side. The picture below depicts how the 2-D display above is saved in memory.

Each row can be seen as a 1-D array, such that a two-dimensional array can be viewed as a single-dimensional array collection. In other terms, we may argue that 2-D arrays are inserted one by one. Arr is an array of 3 components, with every item having a 4-digit 1-D array.