[img]attachment/%e6%9c%aa%e5%91%bd%e5%90%8d.bmp[/img]#include <stdio.h>
main()
{
int i=0,j=0;
float a[3][3]={0,1,2,3,4,5,6,7,8};
printf("&a[0]=%p\n",a[0]);
printf("&a[1]=%p\n",a[1]);
printf("&a[2]=%p\n\n",a[2]);
printf("&a[0][0]=%p\n",&a[0][0]);
printf("&a[1][0]=%p\n",&a[1][0]);
printf("&a[2][0]=%p\n",&a[2][0]);
printf("&a[2][2]=%p\n",&a[2][2]);
printf("\n&a[0]+1=%p\n",a[0]+1);
printf("&a[1]+1=%p\n",a[1]+1);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\na[%d][%d]=%p\t",i,j,&a[i][j]);
}
}
for(i=0;i<3;i++)
{
printf("\na+%d=%p\n\n",i,a+i);
}
//printf("%f\n",*(a[1]+2));
printf("sizeof:a[0]==%d\n",sizeof(a[0]));
printf("sizeof:a[1]==%d\n",sizeof(a[1]));
printf("sizeof:a[2]==%d\n",sizeof(a[2]));
printf("\nsizeof a = %d\n",sizeof(a));
for(i=0;i<3;i++)
{
printf("\n&(a[0]+%d)=%p\n",i,a[0]+i);
}
for(i=0;i<3;i++)
{
printf("\n&(a[1]+%d)=%p\n",i,a[1]+i);
}
for(i=0;i<3;i++)
{
printf("\n&(a[2]+%d)=%p\n",i,a[2]+i);
}
printf("\n&a+0=%p\n",a+0);
printf("\n&a+1=%p\n",a+1);
printf("\n&a+2=%p\n",a+2);
printf("&(a[1]+2)=%p\n",a[1]+2);
printf("\na[1]+2=%f\n",*(a[1]+2));
printf("&(a+1)=%p\n",a+1);
printf("a+1=%f\n",*(a+1));
}
float a[3][3]={0,1,2,3,4,5,6,7,8};
&a[0]=0xbfbfeac0
&a[1]=0xbfbfeacc
&a[2]=0xbfbfead8
&a[0][0]=0xbfbfeac0
&a[1][0]=0xbfbfeacc
&a[2][0]=0xbfbfead8
&a[2][2]=0xbfbfeae0
a[0][0]=0xbfbfeac0
a[0][1]=0xbfbfeac4
a[0][2]=0xbfbfeac8
a[1][0]=0xbfbfeacc
a[1][1]=0xbfbfead0
a[1][2]=0xbfbfead4
a[2][0]=0xbfbfead8
a[2][1]=0xbfbfeadc
a[2][2]=0xbfbfeae0
a+0=0xbfbfeac0
a+1=0xbfbfeacc
a+2=0xbfbfead8
sizeof a = 36
sizeof:a[0]==12
sizeof:a[1]==12
sizeof:a[2]==12
&(a[0]+0)=0xbfbfeac0
&(a[0]+1)=0xbfbfeac4
&(a[0]+2)=0xbfbfeac8
&(a[1]+0)=0xbfbfeacc
&(a[1]+1)=0xbfbfead0
&(a[1]+2)=0xbfbfead4
&(a[2]+0)=0xbfbfead8
&(a[2]+1)=0xbfbfeadc
&(a[2]+2)=0xbfbfeae0
&a+0=0xbfbfeac0
&a+1=0xbfbfeacc
&a+2=0xbfbfead8
&(a[1]+2)=0xbfbfead4
a[1]+2=5.000000
&(a+1)=0xbfbfeacc
a+1=5.000003
main()
{
int i=0,j=0;
float a[3][3]={0,1,2,3,4,5,6,7,8};
printf("&a[0]=%p\n",a[0]);
printf("&a[1]=%p\n",a[1]);
printf("&a[2]=%p\n\n",a[2]);
printf("&a[0][0]=%p\n",&a[0][0]);
printf("&a[1][0]=%p\n",&a[1][0]);
printf("&a[2][0]=%p\n",&a[2][0]);
printf("&a[2][2]=%p\n",&a[2][2]);
printf("\n&a[0]+1=%p\n",a[0]+1);
printf("&a[1]+1=%p\n",a[1]+1);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\na[%d][%d]=%p\t",i,j,&a[i][j]);
}
}
for(i=0;i<3;i++)
{
printf("\na+%d=%p\n\n",i,a+i);
}
//printf("%f\n",*(a[1]+2));
printf("sizeof:a[0]==%d\n",sizeof(a[0]));
printf("sizeof:a[1]==%d\n",sizeof(a[1]));
printf("sizeof:a[2]==%d\n",sizeof(a[2]));
printf("\nsizeof a = %d\n",sizeof(a));
for(i=0;i<3;i++)
{
printf("\n&(a[0]+%d)=%p\n",i,a[0]+i);
}
for(i=0;i<3;i++)
{
printf("\n&(a[1]+%d)=%p\n",i,a[1]+i);
}
for(i=0;i<3;i++)
{
printf("\n&(a[2]+%d)=%p\n",i,a[2]+i);
}
printf("\n&a+0=%p\n",a+0);
printf("\n&a+1=%p\n",a+1);
printf("\n&a+2=%p\n",a+2);
printf("&(a[1]+2)=%p\n",a[1]+2);
printf("\na[1]+2=%f\n",*(a[1]+2));
printf("&(a+1)=%p\n",a+1);
printf("a+1=%f\n",*(a+1));
}
float a[3][3]={0,1,2,3,4,5,6,7,8};
&a[0]=0xbfbfeac0
&a[1]=0xbfbfeacc
&a[2]=0xbfbfead8
&a[0][0]=0xbfbfeac0
&a[1][0]=0xbfbfeacc
&a[2][0]=0xbfbfead8
&a[2][2]=0xbfbfeae0
a[0][0]=0xbfbfeac0
a[0][1]=0xbfbfeac4
a[0][2]=0xbfbfeac8
a[1][0]=0xbfbfeacc
a[1][1]=0xbfbfead0
a[1][2]=0xbfbfead4
a[2][0]=0xbfbfead8
a[2][1]=0xbfbfeadc
a[2][2]=0xbfbfeae0
a+0=0xbfbfeac0
a+1=0xbfbfeacc
a+2=0xbfbfead8
sizeof a = 36
sizeof:a[0]==12
sizeof:a[1]==12
sizeof:a[2]==12
&(a[0]+0)=0xbfbfeac0
&(a[0]+1)=0xbfbfeac4
&(a[0]+2)=0xbfbfeac8
&(a[1]+0)=0xbfbfeacc
&(a[1]+1)=0xbfbfead0
&(a[1]+2)=0xbfbfead4
&(a[2]+0)=0xbfbfead8
&(a[2]+1)=0xbfbfeadc
&(a[2]+2)=0xbfbfeae0
&a+0=0xbfbfeac0
&a+1=0xbfbfeacc
&a+2=0xbfbfead8
&(a[1]+2)=0xbfbfead4
a[1]+2=5.000000
&(a+1)=0xbfbfeacc
a+1=5.000003
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/841/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2007-12-28 19:10
评论列表