我遇到了这个片段:
#include<stdio.h>
int main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
return 0;
}
输出:垃圾值---- 1
这是解释:
p=&a[2][2][2] you declare only two 2D arrays, but you are trying to access
the third 2D(which you are not declared) it will print garbage values. *q=***a starting address of a is assigned integer pointer. Now q is pointing to starting address of a. If you print *q, it will print first element of 3D array.
但是,我仍然无法理解。我希望以易于理解的方式提供相同的内容(并不是我在抱怨上述解释)。
请提供第 6 行和第 7 行的说明。