C Programming on the IBM PC (C Programmers Reference Guide Series)

Although sizeof is also a keyword, it is a compile-time operator that determines the size, in bytes, of a variable or data type, including classes, structures, and unions. If used with a type, the type name must be enclosed by parentheses.

For most 32-bit compilers, the following example prints the number 4:

int x; cout << sizeof x;

For C99, sizeof is evaluated at runtime when it is applied to a variable-length array.

Категории