来哦金额各种数据类型有助于我们对这门语言的更好掌握,更好的利用之来编程,下面是一个简单的获得数据类型的大小的程序,虽然简单,但实用性却很高。
#include <iostream>
using namespace std;
int main()
{
cout<<"confirm those dataType's size in ram"<<endl;
cout<<"int :"<<sizeof(int)<<endl;
cout<<"short int :"<<sizeof(short int)<<endl;
cout<<"long int :"<<sizeof(long int)<<endl;
cout<<"float :"<<sizeof(float)<<endl;
cout<<"double :"<<sizeof(double)<<endl;
cout<<"char :"<<sizeof(char)<<endl;
cout<<"the end!"<<endl;
return 0;
}
程序运行结果如下: