69,382
社区成员
发帖
与我相关
我的任务
分享
#include <iostream.h>
int main()
{
unsigned short a=0; // unsigned short 类型的范围是 0~65535.
unsigned long b=32765; // unsigned long 类型的范围是 0~4294967295.
a=(unsigned short)b; // 当直接转化时,会给出警告:数据可能丢失。而通过强制类型转换就可以了
cout << a << endl;
return 0;
}
#include <iostream.h>
int main()
{
unsigned short a=0; // unsigned short 类型的范围是 0~65535.
unsigned long b=32765; // unsigned long 类型的范围是 0~4294967295.
a=static_cast<unsigned short>b; // 通过强制类型转换太霸道了
cout << a << endl;
return 0;
}
a=(unsigned short)b;
a=(unsigned short)b
c=(unsinged long long)d(这个还真少用C99才有)