Sizeof operator in C:
In C programming, the unary operator sizeof() returns the size of its operand in bytes. The sizeof() operator is discussed in detail in this article, along with illustrative examples of code.
Sizeof() is used extensively in the C programming language. It is a compile-time unary operator, which can be used to compute the size (in bytes) of any data type of its operands. The operand may be an actual type-specifier (such as char or ints) or any valid expression. The sizeof() operator returns the total memory allocated for a particular object in terms of bytes. The resultant type of the sizeof() operator is size_t. Sizeof() can be applied both for primitive data types (such as char, ints, floats, etc) including pointers and also for the compound data types (such as structures, unions, etc). The sizeof() operator can be used in two different cases depending upon the operand types.
Below URL is to download the PDF version of the article (sizeof_operator_in_c_tutorial.pdf), let us know what you think about this tutorial.
Sizeof operator in C – A practical tutorial (Download PDF)
According to the C99 standards, the sizeof() operator yields the size (in integer bytes) of its operand, which may be an expression or the parenthesized name of a type. If the type of the operand is a variable length array type, the operand is evaluated at run-time; otherwise, the operand is not evaluated and the result is an integer constant, during the compile time itself.
About the author:
The author is a member of the embedded software team at Emertxe Information Technology (P) Ltd (http://www.emertxe.com). His areas of interest are embedded C programming combined with data structures and micro-controllers. He can be reached at email@example.com