本帖最后由 fangbuqianxing 于 2016-3-30 00:05 编辑
强调二维数组的数组名是二级指针
分析a与a+i与*(a+i)与*(*(a+i)+j)之间的关系
# include<stdio.h>
int main()
{
int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
printf("a =%p\n",a);
printf("*a =%p\n",*a);//证明数组名a是一个二级指针
printf("a[0] =%p\n",a[0]);
printf("*a[0] =%d\n",*a[0]);
printf("&a[0] =%p\n",&a[0]);
printf("&a[0][0] =%p\n",&a[0][0]);
printf("**a =%d\n",**a);
printf("a+1 =%p\n",a+1);
printf("*(a+1) =%p\n",*(a+1));
printf("*(a+1)+1 =%p\n",*(a+1)+1);
printf("*(*(a+1)+1)=%d\n",*(*(a+1)+1));
printf("**(a+1) =%d\n",**(a+1));
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
//printf("%d\t",a[j]);
printf("%d\t",*(*(a+i)+j)); //*(*(a+i)+j)=a[j]
}
printf("\n");
}
return 0;
}
/*
a =0018FF18
*a =0018FF18
a[0] =0018FF18
*a[0] =1
&a[0] =0018FF18
&a[0][0] =0018FF18
**a =1
a+1 =0018FF28
*(a+1) =0018FF28
*(a+1)+1 =0018FF2C
*(*(a+1)+1)=6
**(a+1) =5
1 2 3 4
5 6 7 8
9 10 11 12
Press any key to continue
*/ |
|