前一天突然研究到一个数据类型以及指针间转化的问题,作为基本功的东西,竟然被它绊倒,惭愧之余,决定彻底搞明白他们之间转化的具体细节
废话少说,上代码:
//#include <string.h>
//#include <iostream>
#include <stdio.h>
int main()
{
int a = 64*1024 + 512 + 3; //a 为 int 型在当前机器中占 4 个字节,a 的字节存储为 00 01 02 03
short b = a; //b 为 short 型在当前机器中占 2 个字节
char c = a; //c 为 char 型在当前机器中占 1 个字节
printf("%d %d %d\n", a, b, c);
}
a = 2^16 + 2^9 + 3
b = 2^9 + 3