首页 编程C/C++将过大的值赋给signed short变量

将过大的值赋给signed short变量

#include <iostream>
int main()
{
 using std::cout;
 using std::endl;
 short int smallNumber;
 smallNumber = 32767;
 cout << “smallNumber :  ” << smallNumber << endl;
 smallNumber++;
 cout << “smallNumber :  ” << smallNumber << endl;
 smallNumber++;
 cout << “smallNumber :  ” << smallNumber << endl;
 smallNumber++;
 cout << “smallNumber :  ” << smallNumber << endl;
 smallNumber++;
 cout << “smallNumber :  ” << smallNumber << endl;
 smallNumber++;
 cout << “smallNumber :  ” << smallNumber << endl;
 return 0;
}