What is a struct or a union? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is a struct or a union?

9th Feb 2019, 8:43 PM
Federico Marcelli
Federico Marcelli - avatar
3 Answers
+ 3
one major difference of structure and union is that the structure has a separate memory location for each of its members whereas, the members of a union share the same memory location. In union, the total memory space allocated is equal to the member with largest size. All other members share the same memory space. This is the biggest difference between structure and union from what i recall
9th Feb 2019, 8:59 PM
peter
peter - avatar
+ 2
data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. so lets say students the share common data right.. structure has three members: name (string), number (integer) and marks in exam (float) we could design a structure to suit. many things show structure i will let others explain union pointers etc lol
9th Feb 2019, 9:09 PM
peter
peter - avatar
+ 1
I don't know what they are... It's also difficult to understand how pointers and memory works...
9th Feb 2019, 8:45 PM
Federico Marcelli
Federico Marcelli - avatar