#include
void main()
{
using std::cout;
cout << "the size of an int is:\t"
<< sizeof(int) << " bytes.\n";
cout << "the size of a short int is:\t"
<< sizeof(short) << " bytes.\n";
cout << "the size of a long int is:\t"
<< sizeof(long) << " bytes.\n";
cout << "the size of a char is:\t"
<< sizeof(char) << " bytes.\n";
cout << "the size of a double is:\t"
<< sizeof(double) << " bytes.\n";
cout << "the size of a float is:\t"
<< sizeof(float) << " bytes.\n";
cout << "the size of a bool is:\t"
<< sizeof(bool) << " bytes.\n";
}
Result:(test on 32bit computer, XP System)
the size of an int is: 4 bytes.
the size of a short int is: 2 bytes.
the size of a long int is: 4 bytes.
the size of a char is: 1 bytes.
the size of a double is: 8 bytes.
the size of a float is: 4 bytes.
the size of a bool is: 1 bytes.
阅读(1153) | 评论(0) | 转发(0) |