#include<iostream>
using namespace std;
int main()
{
cout << "各种数据类型占的字节数:" << endl;
cout << endl;
cout << "bool:" << "\t" << "\t" << sizeof(bool)<< endl;
cout << endl;
cout << "char:" << "\t" << "\t" << sizeof(char) << endl;
cout << "wchar_t:" << "\t" << sizeof(wchar_t) << endl;
cout << endl;
cout << "short:" << "\t" << "\t" << sizeof(short) << endl;
cout << "int:" << "\t" << "\t" << sizeof(int) << endl;
cout << "long:" << "\t" << "\t" << sizeof(long) << endl;
cout << "float:" << "\t" << "\t" << sizeof(float) << endl;
cout << endl;
cout << "double:" << "\t" << "\t" << sizeof(double) << endl;
cout << "long double:" << "\t" << sizeof(long double) << endl;
return 0;
}
运行结果如下: