Structure | Union |
Structure stores each member in a sequence of order in the memory. | Union stores members in overlapping memory where starting |
structure has a size which is sum of individual member | union has has the same size as the maximum size of an member |
Syntax: struct <name> { <type> <member name 1>; <type> <member name 2>; ... <type> <<member name N>; }; |
Syntax: union <name> { <type> <member name 1>; <type> <member name 2>; ... <type> <member name N>; }; |
Individual member of structure can be accessed independently and writing a new value will not affect other members. | Individual member of union cannot be accessed independently, modifying a member can result in modifing the values of other members |
About our authors: Team EQA
You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.