谁能直观地解释一下2D 数组是如何存储在内存中的: a , &a , &a[0] , a[0] 都有相同的地址......在某种程度上它似乎是一个指向自身的指针。 ..那不可能是正确的...这已经困扰了我将近一年,并且在网上搜索也导致我没有合适的答案.....非常感谢您的帮助....thanx
enter code here
#include<stdio.h>
int main()
{
int a[2][3]={10,20,30,40,50,60};
int row =0,col=0;
printf("&a = %d ",&a);
printf("\na = %d ",a);
printf("\n&a[0] = %d ",&a[0]);
printf("\na[0] = %d ",a[0]);
printf("\n&a[1] = %d ",&a[1]);
printf("\na[1] = %d ",a[1]);
printf("\n&a[0][0] = %d ",&a[0][0]);
int *p;
printf("\n\n sizeof(p) = %d ",sizeof(p) );
printf("\n\n sizeof(a) = %d ",sizeof(a) );
printf("\n\n sizeof(&a) = %d ",sizeof(&a) );
printf("\n\n sizeof(&a[0]) = %d ",sizeof(&a[0]) );
printf("\n\n sizeof(a[0]) = %d ",sizeof(a[0]) );
printf("\n\n sizeof(&a[1]) = %d ",sizeof(&a[1]) );
printf("\n\n sizeof(a[1]) = %d ",sizeof(a[1]) );
printf("\n\n sizeof(&a[0][0]) = %d ",sizeof(&a[0][0]) );
}
输出
&a = 2293536
a = 2293536
&a[0] = 2293536
a[0] = 2293536
&a[1] = 2293548
a[1] = 2293548
&a[0][0] = 2293536
sizeof(p) = 4
sizeof(a) = 24
sizeof(&a) = 4
sizeof(&a[0]) = 4
sizeof(a[0]) = 12
sizeof(&a[1]) = 4
sizeof(a[1]) = 12
sizeof(&a[0][0]) = 4
不要让我参考C 中二维数组的内存映射 ...这没有帮助...