VC++2005 中各基本类型的大小

得到基本数据类型的字节数

#include <iostream>
using namespace std;
void main()
{
	/*显示为所占字节数*/
	cout<<"bool:"<<sizeof(bool)<<endl;
	cout<<"char:"<<sizeof(char)<<endl;
	cout<<"signed char:"<<sizeof(signed char)<<endl;
	cout<<"unsigned char:"<<sizeof(unsigned char)<<endl;
	cout<<"wchar_t:"<<sizeof(wchar_t)<<endl;
	cout<<"short:"<<sizeof(short)<<endl;
	cout<<"unsigned short:"<<sizeof(unsigned short)<<endl;
	cout<<"int:"<<sizeof(int)<<endl;
	cout<<"unsigned int:"<<sizeof(unsigned int)<<endl;
	cout<<"long:"<<sizeof(long)<<endl;
	cout<<"unsigned long:"<<sizeof(unsigned long)<<endl;
	cout<<"float:"<<sizeof(float)<<endl;
	cout<<"double:"<<sizeof(double)<<endl;
	cout<<"long double"<<sizeof(long double)<<endl;

}

posted on 2011-08-09 15:00  天上星  阅读(258)  评论(0编辑  收藏  举报

导航