&a是 int (*) [5] 的类型,,&a+1 就加了 5*4个字节(5*4); sizeof(int (*)[5]) = 20; //sizeof(int[5]) = 20;
pt 是 int * 的类型,,pt-1 就是 后退4个字节,因为sizeof(int * ) = 4
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
int a[] = {1,2,3,4,5};
int* pt = (int*)(&a);
printf("int* pt = (int*)(&a);\n");
printf("*pt = %d\n",*pt);
pt = (int*)(&a + 1);
printf("pt = (int*)(&a + 1);\n");
printf("&a[0] = %d\n",&a[0]);
printf("&a[1] = %d\n",&a[1]);
printf("&a[2] = %d\n",&a[2]);
printf("&a[3] = %d\n",&a[3]);
printf("&a[4] = %d\n",&a[4]);
printf("*pt = %d\n",*pt);
printf("pt = %d\n",pt);
printf("*(pt-1) = %d\n",*(pt - 1));
return 0;
}