What are some real life problems where unions and structure data types in c are used? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What are some real life problems where unions and structure data types in c are used?

What would the real case scenario apart from data management where we can classify the use of structures and unions

21st Jun 2020, 7:50 PM
D.Balaji Reddy
D.Balaji Reddy - avatar
1 Answer
+ 1
Everywhere in modern C. The structures that you see in textbooks on C are just for old times sake now. Modern C almost always uses structures and unions and in my experience I haven't seen a C code after C99 that doesn't use a structure atleast for some cases. Structures and Unions can also have thier respective holder predicates and function pointers which can be used to generate loose bound classes. Most of the Standard Libraries of C11 don't use just plain C data types anymore, they use structures and unions which are cast to a name. Examples can be : uint16_t, int64, wchar_t, etc.
24th Jun 2020, 5:41 PM
Anubhav Mattoo
Anubhav Mattoo - avatar