一直以为short的大小和int是一样的,结果看《programming windows》的时候发现上面写的不一样,写了一个程序测试了一下,果然。
记忆中,short 的字节大小是和int的最小值相等,而long是和int的最大值相等。
测试环境:VS.NET 2003, WinXP, IA32
测试代码:test.cpp
#include
<
iostream
>
using
namespace
std;

typedef unsigned
short
wchar;

int
main()
{
cout<<sizeof(char)<<endl;
cout<<sizeof(wchar)<<endl;
cout<<sizeof(unsigned int)<<endl;
cout<<sizeof(unsigned long)<<endl;
cout<<sizeof(float)<<endl;
cout<<sizeof(double)<<endl;
}
测试结果:
记忆中,short 的字节大小是和int的最小值相等,而long是和int的最大值相等。
测试环境:VS.NET 2003, WinXP, IA32
测试代码:test.cpp















测试结果: