c++中各个数据类型的大小

来源:互联网 发布:美国网络电视台 nefix 编辑:程序博客网 时间:2024/05/21 11:25

来哦金额各种数据类型有助于我们对这门语言的更好掌握,更好的利用之来编程,下面是一个简单的获得数据类型的大小的程序,虽然简单,但实用性却很高。

#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;}

程序运行结果如下:
程序运行结果

0 0
原创粉丝点击