How are you? Today is rainy day in sirsa.Mood is fresh so i decide to write about structure and union.friends let us discuss about structure and union.
STRUCTURE:-Structure is a heterogenous combinations of data types.It is user defined data type.
struct element 1;
struct element 2;
struct element n;
UNION:-Union is also a user defined data type as structure but there is only some difference for accessing elements,memory allocation and syntex,which i discuss later.
Difference between structure and union:-
1.Structure elements can be accessed more then one at one time but only one element of union can be accessed at once.
2.Structure elements store at separate location each but elements of unions share same memory space.
3.Memory space for each elements in structure allocate as per data type but in union only space required maximum element type is allocate and share by other elements too.
4.Elements of structure can be initialized at the time of declaration but not posible in case of elements of union.