Chinaunix首页 | 论坛 | 博客
  • 博客访问: 385842
  • 博文数量: 61
  • 博客积分: 1546
  • 博客等级: 中尉
  • 技术积分: 708
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-22 20:07
文章分类

全部博文(61)

文章存档

2011年(61)

分类: C/C++

2011-06-07 21:43:23

#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.
阅读(1133) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~