提示:运行机器为32bit x86架构, Little Endian
int a[20];
char *p1 = (char * )a;
char *p2 = (char *)(a+5);
int n=p2-p1;
int k = 0x123456;
char *p = (char*) &k;
printf("n = %d/nk = %x/n", n, *p);
(来源:兵马俑BBS C_Cpp区,作者:echo (找不到MM的都是loser))
将程序改为:
int a[20];
int *p1 = (int *)a;
int *p2 = (int *)(a+5);
int n=p2-p1;
int k = 0x123456;
int *p = (int *) &k;
printf("n = %d/nk = %x/n", n, *p);
看看结果有何不同?