【发布时间】:2012-10-03 19:07:03
【问题描述】:
请考虑以下代码
#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2
int main()
{
int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};
// Base address:Pointer to the first element a 1D array
printf("Base address of array:%p\n",a);
//The value at the base address: should be the address of 1st 1D array
printf("Value at the Base address:%p\n",*a);
return 0;
}
得到的输出:
Sample Output:
Base address of array:0xbff77434
Value at the Base address:0xbff77434
不知何故,我无法理解 2D 数组的基地址的概念和基地址的值,而基地址的值又是 1D 数组的地址。请解释一下。
【问题讨论】:
标签: c arrays pointers multidimensional-array