Notice: Undefined variable: meta in /home/customer/www/demo.emertxe-group.com/public_html/wp-content/themes/Divi-child/functions.php on line 1116

Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /home/customer/www/demo.emertxe-group.com/public_html/wp-content/plugins/divi-filterable-blog-module/includes/controller/autoloader.php on line 94
Sizeof operator in C - Tutorial with practical examples

Emertxe-News & Blog

Home » C programming » Sizeof operator in C – A practical tutorial
Sizeof operator in C – A practical tutorial
sizeof operator in C

sizeof operator in C – Usage

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

Best Embedded systems training institute with placements in Bangalore.

YOU MAY ALSO LIKE

The Future of Embedded Systems : Trends and Predictions

The Future of Embedded Systems : Trends and Predictions

Introduction Embedded systems have become an integral part of modern technology, and their importance is increasing day by day. These systems are designed to perform specific tasks and are embedded in everyday devices, making them intelligent and interactive. From...

Online Free IoT Internship for Engineering Students – 2023

Online Free IoT Internship for Engineering Students – 2023

The Internship Ecosystem An internship is a type of professional learning opportunity where engineering students get practical work related to their field of study or career interest. Through an internship, a student can explore and advance their career while...

1 Comment

  1. Irfan

    Most common question on data types is based on its size thank you so much for sharing this type of blog

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *