Q

Emertxe-News & Blog

Home » Embedded » Sizeof operator in C – A practical tutorial
Sizeof operator in C – A practical tutorial

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)

Interesting note:

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 satya@emertxe.com

YOU MAY ALSO LIKE

Emertxe’s Online Training Programs in Embedded Systems & IoT

Emertxe’s Online Training Programs in Embedded Systems & IoT

The reason why Emertxe is the best choice for career advancement: eLearning and Online training programs are the way forward in the COVID-19 disrupted world. Riding along the digital revolution will ensure engineers are future-ready with skills to not only secure but...

Our Training Programs for Freshers

Our Training Programs for Freshers

Introduction: Emertxe is the leading training institute in Bangalore for Embedded Systems and IoT domains. It is a pioneer in training freshers since 2003 by providing excellent placement opportunities for freshers. Over the years 70000+ students have made their...

Q