Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 1
With a union you can switch between different data types but you can only assign one value to a union. So you dont have to allocate memory space for all elements. Instead you only allocate memory for the biggest data type in the union, so all data types of the elements in the union will fit in this memory location. In a struct you allocate memory for all declared variables.
+ 1
Please use the search bar.
https://www.sololearn.com/discuss/1609349/?ref=app
https://www.sololearn.com/discuss/117597/?ref=app
https://www.sololearn.com/discuss/2066802/?ref=app
https://www.sololearn.com/discuss/1215623/?ref=app
https://www.sololearn.com/discuss/96904/?ref=app
https://www.sololearn.com/discuss/1899315/?ref=app