先看源码。
#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;
}