I've been searching on internet and trying to understand how union is different then structure in c language
structure is use to hold different type of data type
In this link https://www.geeksforgeeks.org/difference-structure-union-c/ there are the six reason I don't understand second reason memory allocation for union and structure
Can anyone help me to understand how union is different then structure in c language ?
structure is use to hold different type of data type
Code:
#include <stdio.h>
struct student{
char *name;
int age;
}record;
int main()
{
record.name = "Ceena";
record.age = 35;
printf("student name : %s", record.name);
printf("\nStudent Age: %d", record.age);
return 0;
}
In this link https://www.geeksforgeeks.org/difference-structure-union-c/ there are the six reason I don't understand second reason memory allocation for union and structure
Can anyone help me to understand how union is different then structure in c language ?