#include <stdio.h>
int main(void) {
static const int buff[5] = {0x40201c,0x200,0x300,0x12345678,0x500};
int* p =NULL;
short temp = 0;
p = (int*)buff[0];
temp = (short)*p;
printf("%p\n",&buff[0]);
printf("%p\n",&buff[1]);
printf("%p\n",&buff[2]);
printf("%p\n",&buff[3]);
printf("%p\n",&buff[4]);
printf("%p\n",p);
printf("0x%x\n",*p);
printf("0x%x\n",temp);
return 0;
}
调试打印结果:
0x402010
0x402014
0x402018
0x40201c
0x402020
0x40201c
0x12345678
0x5678
指针取数组元素值为其指针地址
最新推荐文章于 2023-10-24 16:33:49 发布