MCS-011 Problem Solving and Programming

First year, Semester 1

Chapters

Newsletter

Size of operator

C provides a compile-time unary operator called sizeof that can be used to compute the size of any object. The expressions such as:

sizeof object                       and                               sizeof(type name) 

result in an unsigned integer value equal to the size of the specified object or type in bytes. Actually the resultant integer is the number of bytes required to store an object of the type of its operand. An object can be a variable or array or structure. An array and structure are data structures provided in C, introduced in latter units. A type name can be the name of any basic type like int or double or a derived type like a structure or a pointer.

For example,
 sizeof(char) = 1bytes
 sizeof(int) = 2 bytes  

Report an issue

Reporting: Size of operator (topic)

Related Posts