sizeof is a unary operator in the C and C++ programming languages that evaluates to the storage size of an expression or a data type, measured in units sized as char
. Consequently, the expression sizeof(char)
evaluates to 1. The number of bits of type char
is specified by the preprocessor macro CHAR_BIT
, defined in the standard include file limits.h. On most modern computing platforms this is eight bits. The result of sizeof is an unsigned integer that is usually typed as size_t.
The operator accepts a single operand which is either a data type expressed as a cast – the name of a data type enclosed in parentheses – or a non-type expression for which parentheses are not required.