2 Dimensional Arrays: Addresses and Values
#include<stdio.h>void main()
{
int a[3][4] = { {10,11,12,13}, {20,21,22,23}, {30,31,32,33} };
int i, j;
for(i=0; i<3; i++)
printf("\n *(a+%d) is %d", i, *(a + i) );
for(i=0;i<3;i++)
{
for(j=0; j<4; j++)
{
printf("\n (*(a+%d) + %d) is %d", i, j, (*(a + i) + j) );
}
}
for(i=0;i<3;i++)
{
for(j=0; j<4; j++)
{
printf("\n *(*(a+%d) + %d) is %d", i, j, *(*(a + i) + j) );
}
}
}
Output:
*(a+0) is 2686736
*(a+1) is 2686752
*(a+2) is 2686768
--------------------------------------
(*(a+0) + 0) is 2686736
(*(a+0) + 1) is 2686740
(*(a+0) + 2) is 2686744
(*(a+0) + 3) is 2686748
(*(a+1) + 0) is 2686752
(*(a+1) + 1) is 2686756
(*(a+1) + 2) is 2686760
(*(a+1) + 3) is 2686764
(*(a+2) + 0) is 2686768
(*(a+2) + 1) is 2686772
(*(a+2) + 2) is 2686776
(*(a+2) + 3) is 2686780
------------------------------------
*(*(a+0) + 0) is 10
*(*(a+0) + 1) is 11
*(*(a+0) + 2) is 12
*(*(a+0) + 3) is 13
*(*(a+1) + 0) is 20
*(*(a+1) + 1) is 21
*(*(a+1) + 2) is 22
*(*(a+1) + 3) is 23
*(*(a+2) + 0) is 30
*(*(a+2) + 1) is 31
*(*(a+2) + 2) is 32
*(*(a+2) + 3) is 33
No comments:
Post a Comment