// a13.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <climits>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n_int=INT_MAX;
short n_short=SHRT_MAX;
long n_long=LONG_MAX;
long long n_llong=LLONG_MAX;
cout<<"int is "<<sizeof(int)<<" bytes."<<endl;
cout<<"short is "<<sizeof(short)<<" bytes"<<endl;
cout<<"long is "<<sizeof(long)<<" bytes."<<endl;
cout<<"long long is "<<sizeof(long long)<<" bytes."<<endl;
cout<<endl<<endl;
cout<<"Maximum Values:"<<endl;
cout<<"int: "<<n_int<<endl;
cout<<"short: "<<n_short<<endl;
cout<<"long: "<<n_long<<endl;
cout<<"long long: "<<n_llong<<endl;
return 0;
}
2017.05.02 有关limits头文件的学习
最新推荐文章于 2022-07-24 22:54:37 发布
本文通过一个简单的C++程序展示了不同整数类型(int, short, long, long long)的大小(占用字节数)及其最大可表示数值。这对于理解C++中整数类型的使用限制和特性非常有帮助。
3217

被折叠的 条评论
为什么被折叠?



