Sizeof Operator
The size of structure and union can be defined by the sizeof operator.
#include <stdio.h>
#include <conio.h>
struct student1
{
int rollno;
char name
[20];
};
union student2
{
int rollno;
char name
[20];
};
main ( )
{
struct
student1 s1;
union
student2 s2;
clrscr( );
printf (“\n
Memory for structure =%d”, sizeof(s1));
printf (“\n
Memory for union =%d”, sizeof(s2));
getch ( );
}
Post a Comment