#include <stdio.h>
typedef unsigned char *byte_pointer;
void show_bytes(byte_pointer start, int len)
{
int i;
for (i = 0; i < len; i++)
printf("%.2x", start[i]);
printf("\n");
}
void show_int(int x)
{
show_bytes((byte_pointer) &x, sizeof(int));
}
int main()
{
int a[5]={1,2,3,4,5};
for (int i = 0; i < 5; i++)
show_int(a[i]);
printf("%d\n",sizeof(int));
int *ptr1=(int *)(&a+1);
int *ptr2=(int *)((int)a+1);
printf("%x,%x\n",ptr1[-1],*ptr2);
return 0;
}
输出结果: