#include <iostream>
using namespace std;
int main()
{
cout<<"number of bytes in int is:"<<sizeof(int)<<endl;
cout<<"number of bytes in long int is:"<<sizeof(long)<<endl;
cout<<"number of bytes in short int is:"<<sizeof(short int)<<endl;
cout<<"number of bytes in long double is:"<<sizeof(long double)<<endl;
cout<<"number of bytes in float is:"<<sizeof(float)<<endl;
cout<<"number of bytes in char is:"<<sizeof(char)<<endl;
return 0;
}
结果是
number of bytes in int is:4
number of bytes in long int is:4
number of bytes in short int is:2
number of bytes in long double is:8
number of bytes in float is:4
number of bytes in char is:1
Press any key to continue