In C, sizeof operator works on following kind of operands:
1) type-name: type-name must be specified in parentheses.
2) expression: expression can be specified with or without the parentheses.
The expression is used only for getting the type of operand and not evaluated. For example, below code prints value of i as 5.
Output of the above program:
size of i = depends on compiler
value of i = 5
- Operators in C | Set 1 (Arithmetic Operators)
- sizeof operator in C
- Bitwise Operators in C/C++
- Difference between ++*p, *p++ and *++p
- A comma operator question
- Result of comma operator as l-value in C and C++
- Order of operands for logical operators
- Increment (Decrement) operators require L-value Expression
- Precedence of postfix ++ and prefix ++ in C/C++
- Modulus on Negative Numbers
- Comma in C and C++
- Evaluation order of operands
- Return values of printf() and scanf() in C/C++
- What are Wild Pointers? How can we avoid?
- What is Memory Leak? How can we avoid?