+ 9

what is difference between union and structure in c program language.

27th May 2019, 10:27 PM
💘 Ŝαđᵃ𝐦 ʰ𝐔ⓢ𝔰ÃιŇ 🎧
💘  Ŝαđᵃ𝐦 ʰ𝐔ⓢ𝔰ÃιŇ  🎧 - avatar
6 ответов
+ 22
Biggest difference between structure and union is==> In structure, all members are stored in different memory location but in union all members are stored in same memory location.
28th May 2019, 1:06 AM
Priyanka♥️
+ 5
With unions, only one of its members can be used at a time and the size of the union is the size of its largest member. With structs you can use all of its members at any time and because of that, the size of a struct is the size of all its members combined.
27th May 2019, 10:54 PM
Cluck'n'Coder
Cluck'n'Coder - avatar
+ 2
In structure every variable are stored in separate memory whereas in union one memory hold all variable .the variable having more space is used to store..
28th May 2019, 6:08 PM
Ajay
Ajay - avatar
+ 1
@piyanka_d_ohol - That's a good point.
28th May 2019, 1:28 AM
Cluck'n'Coder
Cluck'n'Coder - avatar