climits文件指出了编译器中符号常量的值。
测试环境:win10 Code::Blocks 17.12
#include<iostream> #include<string> #include<climits> using namespace std; int main() { cout<<"char 的位数: "; cout<<CHAR_BIT<<endl; cout<<"char 的最小值: "; cout<<CHAR_MIN<<endl; cout<<"char 的最大值: "; cout<<CHAR_MAX<<endl; cout<<"signed char 的最小值: "; cout<<SCHAR_MIN<<endl; cout<<"signed char 的最大值: "; cout<<SCHAR_MAX<<endl; cout<<"unsigned char 的最大值: "; cout<<UCHAR_MAX<<endl; cout<<"short 的最小值: "; cout<<SHRT_MIN<<endl; cout<<"short 的最大值: "; cout<<SHRT_MAX<<endl; cout<<"unsigned short 的最大值: "; cout<<USHRT_MAX<<endl; cout<<"int 的最小值: "; cout<<INT_MIN<<endl; cout<<"int 的最大值: "; cout<<INT_MAX<<endl; cout<<"unsigned int 的最大值: "; cout<<UINT_MAX<<endl; cout<<"long 的最小值: "; cout<<LONG_MIN<<endl; cout<<"long 的最大值: "; cout<<LONG_MAX<<endl; cout<<"unsigned long 的最大值: "; cout<<ULONG_MAX<<endl; cout<<"longlong 的最小值: "; cout<<LLONG_MIN<<endl; cout<<"longlong 的最大值: "; cout<<LLONG_MAX<<endl; cout<<"unsigned longlong 的最大值:"; cout<<ULLONG_MAX<<endl; return 0; }