#include<stdio.h>
int main()
{
int array[3][4]={{11,12,13,14},{21,22,23,24},{31,32,33,34}};
int i,j,*pointer;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
printf("%d ",array[i][j]);
printf("\n");
}
printf("array=%d\n",array);
printf("Address of array[0][1]=%d\n",&array[0][1]);
printf("array[0]=%d\n",array[0]);
printf("array+1=%d\n",array+1);
printf("*(array+1)=%d\n",*(array+1));
printf("*(*(array+1))=%d\n",*(*(array+1)));
printf("*(*(array+1)+1)=%d\n",*(*(array+1)+1));
}
結果是:
11 12 13 14
21 22 23 24
31 32 33 34
array=-1080173016
Address of array[0][1]=-1080173012
array[0]=-1080173016
array+1=-1080173000
*(array+1)=-1080173000
*(*(array+1))=21
*(*(array+1)+1)=22
行指針:array + i ----指向第i行數組
array[i] ----指向第i行數組
列指針:*(array + i) + j -----指向第 i 行 j 列
array[i]+j
數值:*((*array+i)+j)
*(array[i]+j) == array[i][j]
作者“cafe”