您的位置:首页 > 其它

一张图:数据类型在不同位平台和编译器下sizeof的字节大小

2018-09-07 13:08 561 查看
先看源码。

#include <iostream>
using namespace std;

struct MyStruct
{
char    a;
int		b;
double  c;
char *  d;
};

int main()
{
cout << "short int:" << sizeof(short int) << endl;
cout << "int:" << sizeof(int) << endl;
cout << "unsigned int:" << sizeof(unsigned int) << endl;

cout << "long:" << sizeof(long) << endl;
cout << "unsigned long:" << sizeof(unsigned long) << endl;
cout << "long long:" << sizeof(long long) << endl;

cout << "float:" << sizeof(float) << endl;

cout << "double:" << sizeof(double) << endl;

cout << "char:" << sizeof(char) << endl;
cout << "char*:" << sizeof(char*) << endl;

cout << "struct MyStruct:" << sizeof(MyStruct) << endl;

return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: