Evaluate Size of Structure Without using Sizeof Operator.
Sizeof operator is used to evaluate the size of any data type or any variable in c programming. Using sizeof operator is straight forward way of calculating size but following program will explain you how to calculate size of structure without using sizeof operator.
#include<stdio.h>
struct
{
int num1,num2;
char s1;
int *ptr;
int abc[5];
}a[2];
void main()
{
int start,last;
start = &a[1].num1;
last = &a[0].num1;
printf("\nSize of Structure : %d Bytes",start-last);
}
Output :
Size of Structure : 17 Bytes