sizeof
Sign in to save'''''' 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 .
~10 min read
Encyclopedic overview
10 sectionsContents
- Purpose
- Use
- Application to arrays
- Incomplete types
- Object members
- Variadic template packs
- Implementation
- Structure padding
- See also
- References
'''''' 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 .
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.
Excerpted from Wikipedia’s “sizeof” article, available under the CC BY-SA 4.0 licence.