Need of union if we have structure | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Need of union if we have structure

Difference between union and structure

29th Jun 2019, 4:13 PM
Kavita Bharti
Kavita Bharti - avatar
5 Answers
+ 11
the size of a structure is the size of all the members in it, while in union it's the biggest member, so think of how that could be of benefit to the memory
29th Jun 2019, 4:30 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 4
As in union its size take the size of biggest member so memory get reduced
7th Jul 2019, 6:14 PM
Kavita Bharti
Kavita Bharti - avatar
+ 1
For reduction of memory size
4th Jul 2019, 2:15 AM
Vicky
Vicky - avatar
0
why don’t we just use union instead if structure then?
30th Jul 2019, 4:56 PM
Jon
Jon - avatar
0
Diffrence is only memory allocation
12th Aug 2019, 11:40 AM
MOHD SADIQUE
MOHD SADIQUE - avatar