Calculate Size of Structure
Size of Structure can be calculated as –
- By observation
- By Using sizeof Operator
- Without using Sizeof Operator
Way 1 : Calculate by adding Individual Sizes
struct Book { int pages; char name[10]; char author[10]; float price; }b1;
Calculating Size of Structure :
Size = size of 'Pages' + size of 'Name' +
size of 'Author' + size of 'Price'
= 2 + 10 * 1 + 10 * 1 + 4
= 2 + 10 + 10 + 4
= 26
Note :
- Add all the individual Size of Each Structure Member .
- Character array requires Memory Equivalent to (No_of_elements * Sizeof(char))
- Float , Integer requires 4,2 bytes respectively in Case of Borland CC++ 3.0
Way 2 : Using Sizeof Operator
printf("Size of Structure : %d",sizeof(b1));Way3 : Without Using Sizeof Operator : Click Here

