用C++写个程序,如何判断一个操作系统是16位还是32位的?不能用sizeof()
一、
16位的系统下:
int i = 65536;
cout << i; //输出0
int i = 65535;
cout << i; //输出-1
32位的系统下:
int i = 65536;
cout << i; //输出65536
int i = 65535;
cout << i; //输出65535
二、
int a = ~0;
if(a>65536)
{
cout << "32 bit" << endl;
}
else
{
cout ,<< "16 bit" << endl;
}
转载于:https://blog.51cto.com/shaxquan/384579