以下C代码的输出是什么?假设x的地址是2000(十进制),并且一个整数需要四个字节的内存。
#include
int main()
{
unsigned int x[4][3] = {{1, 2, 3}, {4, 5, 6},
{7, 8, 9}, {10, 11, 12}};
printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}
(A) 2036、2036、2036
(B) 2012,4,2204
(C) 2036、10、10
(D) 2012,4,6答案: (A)
解释:
x = 2000
Since x is considered as a pointer to an
array of 3 integers and an integer takes 4
bytes, value of x + 3 = 2000 + 3*3*4 = 2036
The expression, *(x + 3) also prints same
address as x is 2D array.
The expression *(x + 2) + 3 = 2000 + 2*3*4 + 3*4
= 2036
这个问题的测验