#include<stdio.h>
int main()
{
int i = 0x1234;
char j = i; // j = 0x34 隐士类型转换
printf("%0x\n",j); // 0x34
char c = j;
printf("%0x\n",c); // 0x34
//int* pI = &c; // error
int* pI = (int*)&c; //c语言规定只有相同类型的指针才可以相互赋值
printf("%08d\n",&c); //打印的是随机值
printf("%08x\n",&c); //打印的是随机值
printf("%p\n",&c); // 0x7ffddbd4739f
printf("%p\n",pI); //0x7ffddbd4739f
*pI = 21; // c == 12
printf("%x\n",c); // c
printf("%d\n",c); // 12
printf("%c\n",c); //按字符值打印
}
在64位的Centos上编译结果
VS2012编译结果: