Consider the following program
Code:
#include <stdio.h>
int main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d" , *(a+1), *(ptr-1) );
}
The output for this program is
备选答案:
A : 2 2
B : 2 1
C : 2 5
D : None of the above
你的回答: B
回答结果: 错
答案: C
解析:
&a是对数组首地址取址,加1是加上一个数组长度。
*(ptr -1)取得就是数组的最后一项的值啦。