在別人文章裡看到的程序
程序的輸出結果是什麼,why?
#include
int main()
{
int a[5] = {1,2,3,4,5};
int p = (int)(&a + 1);
printf("%d, %d\n", *(a + 1), *(p -1));
}
int a[5] = {1,2,3,4,5};
int* p = (int*)(&a + 1);
printf("%d, %d\n", *(a + 1), *(p -1));
結果2,5
&a + 1 = a + sizeof a / sizeof int
a+1 = a[1]