标签:
#include <stdio.h> int main() { int a[5] = {1, 2, 3, 4, 5}; int* p1 = (int*)(&a + 1); // <==> (unsigned int)&a+sizeof(*&a) => 整个数组后面的那个地址 int* p2 = (int*)((int)a + 1); <=> 取a[0]后三个字节拼接a[1]第一个字节 => 0x02000000 int* p3 = (int*)(a + 1); <=> a[2] printf("%d\n", p1[-1]); // (unsigned int)p1-1*sizeof(*p1) => a[4] printf("%d\n", p2[0]); // 0x02000000 printf("%d\n", p3[1]); // a[3] return 0; }
标签:
原文地址:http://www.cnblogs.com/siqi/p/4695739.html