With the help of example we are comparing Union and Structure
#include<stdio.h>
struct Employee1
{
int Id;
char Name[25];
long Salary;
};
union Employee2
{
int Id;
char Name[25];
long Salary;
};
void main()
{
printf("\nSize of Employee1 is : %d",sizeof(struct Employee1));
printf("\nSize of Employee2 is : %d",sizeof(union Employee2));
}
Output
No comments:
Post a Comment