一、代码查看
#include <iostream>
#include <climits>
using namespace std;
int main(void)
{
cout << "signed char is " << sizeof(char) << " bytes." << endl;
cout << "signed int is " << sizeof(int) << " bytes." << endl;
cout << "signed short is " << sizeof(short) << " bytes." << endl;
cout << "signed long is " << sizeof(long) << " bytes." << endl;
cout << "signed long long is " << sizeof(long long) << " bytes." << endl << endl;
//下面宏都是climits头文件中所定义,可打开改头文件观察
cout << "Maxinum values and Mininum values: " << endl;
cout << "signed char : " << SCHAR_MIN << " -- " << SCHAR_MAX << endl;
cout << "signed int : " << INT_MAX << " -- "<< INT_MIN << endl;
cout << "signed short : " << SHRT_MIN << " -- " << SHRT_MAX << endl;
cout << "signed long : " << LONG_MIN << " -- " << LONG_MAX << endl;
cout << "signed long long : " << LLONG_MIN << " -- " << LLONG_MAX << endl;
return 0;
}
二、结果显示
int
类型10^9,超出就要使用long long
类型