简述:
sizeof是一个很像函数的运算符,也是唯一一个用到字母的运算符。其作用是返回指定的数据类型或表达式值的数据类型在内存中占用字节数。该运算符有两种形式:
(1)形式一
sizeof(类型说明符):指定的数据类型
#include <iostream>
using namespace std;
int main()
{
cout << "Size of char : " << sizeof(char) << endl;
cout << "Size of int : " << sizeof(int) << endl;
cout << "Size of short int : " << sizeof(short int) << endl;
cout << "Size of long int : " << sizeof(long int) << endl;
cout << "Size of float : " << sizeof(float) << endl;
cout << "Size of double : " << sizeof(double) << endl;
cout << "Size of wchar_t : " << sizeof