Let a be an one dimensional array of 10 integers as shown below
int a[10];
and for above declared array the expression
a[i]
is evaluated as *(a+i) and gives the value stored at the ith index,e.g.
int a[5]={1,2,3,4,5};
here a[3] is evaluated as *(a+3) which is equal to 4 ,i.e. the value of element stored at 3rd index of array a. But in case of a 2D array like this one
int b[2][3]={ {1,2,3},{4,5,6} };
(here I am thinking of 2D array b as array of 1D arrays,i.e. b is a 1D array having 2 elements,each element itself being an 1D array of 3 int) if we use single subscript operator with array name as
b[i]
the above expression for i=1 gives address where the element 4 is stored,so
- How is the expression b[i] evaluated in case when b is 2D array?
- How is the expression b[i][j] evaluated in case when b is 2D array?
- How to access elements of a Multi-dimensional Array in C using pointers. Here I would like to know about how compiler treats a Multi-dimensional Array internally ?
- What does b evaluate to if b is a 2D array?