数据类型及其占用空间
#include<iostream>
using namespace std;
int main()
{
	cout << "The size of int is " <<sizeof(int) <<endl;
	cout << "The size of short is " <<sizeof(short) <<endl;
	cout << "The size of long is " <<sizeof(long) <<endl;
	cout << "The size of bool is " <<sizeof(bool) <<endl;
	cout << "The size of char is " <<sizeof(char) <<endl;
	cout << "The size of float is " <<sizeof(float) <<endl;
	cout << "The size of double is " <<sizeof(double) <<endl;
	return 0;
}运行的结果是
The size of int is 4 The size of short is 2 The size of long is 4 The size of bool is 1 The size of char is 1 The size of float is 4 The size of double is 8
单位是字节



