1#include<stdio.h>
2//accessing elements of 2D array using pointers
3int main(void){
4
5 int arr[4][4]={{1,2,3,4},{5,6,7,8},{9,0,1,2}};
6 int *ptr = &arr;
7
8 //accessing the elements of 2D array using ptr
9 for(int i=0;i<3;i++){
10 for(int j=0;j<4;j++)
11 printf("%d ",*((ptr+i*4)+j)); //4 is the number of columns
12 //*((ptr+i*4)+j) is similar to arr[i][j]
13 printf("\n");
14 }
15 return 0;
16}
1/*any type*/ array2d[nRows][nCol];
2// normal 2D array accessing
3array2d[iRow][jCol] = value1;
4bool b = array2d[iRow][jCol] == value1;
5// accessing 2D array with pointers
6*(*(array2d + iRow) + jCol) = value2;
7b = *(*(array2d + iRow) + jCol) == value2;