char temp = 0x80;
cout << "unsigned short of 0x80=" << dec << (unsigned short)temp <<endl; //输出:unsigned short of 0x80=65408
cout << "short of 0x80=" << dec << (short)temp <<endl; //输出:short of 0x80=-128
unsigned char ttt = 0x80;
cout << "unsigned short of (unsigned char)0x80=" << dec << (unsigned short)ttt <<endl; //输出:unsigned short of (unsigned char)0x80=128
cout << "short of (unsigned char)0x80=" << dec << (short)ttt <<endl; //输出:short of (unsigned char)0x80=128
C++中char转换short(或者int)要注意的现象
最新推荐文章于 2023-11-01 23:58:48 发布