您的位置:首页 > 编程语言 > C语言/C++

C++基本类型的大小

2011-07-21 15:25 288 查看
cout  << "size of (char) : " << sizeof(char) << endl
<< "size of (int) : " << sizeof(int) << endl
<< "size of (unsigned int) : " << sizeof(unsigned int) << endl
<< "size of (long) : " << sizeof(long) << endl
<< "size of (unsigned long) : " << sizeof(unsigned long) << endl
<< "size of (float) : " << sizeof(float) << endl
<< "size of (double) : " << sizeof(double) << endl
<< "size of (short) : " << sizeof(short) << endl;

在vc 6.0上的结果是:



可以看出int 和 long 的大小在win32平台上是一样的。而C++标准只要求 sizeof(long) >= sizeof(int) >= sizeof(short) 即可。
另常见的typedef

#define UINT32 int
#define UINT unsigned int
#define DWORD unsigned long
#define LONG long
#define WORD unsigned short
#define BYTE char
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: