1/11/00
COM1100 Winter2000 Yuhong Yin Northeastern University
35
sizeof operator
q       C++ provides a special operator sizeof which gives the size in bytes of any data type
qcout << "unsigned char = " << sizeof(unsigned char) << endl;  // unsigned char = 1
qcout << "char = " << sizeof(char) << endl;     // char = 1
qcout << "short = " << sizeof(short) << endl; // short = 2
qcout << "int = " << sizeof(int) << endl; // int = 4
qcout << “float = " << sizeof(float) << endl; // float = 4
qcout << “double = " << sizeof(double) << endl;
q   // double = 8
q
n