What Is Union In C Language?


5 Answers

rohit kamalasanan Profile

Union is a collection of heterogeneous data type but it uses efficient memory utilization technique by allocating enough memory to hold the largest member. Here a single area of memory contains values of different types at different time. A union can never be initialized.

for more info visit this page

Florio Potter Profile
Florio Potter answered

A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose. For detail information must visit Best & Affordable Computer Science Homework Help

Neeraj Khosla Profile
Neeraj Khosla answered
It can be treated as a user-defined data type just like structure. The difference between the structure and union is that where each member present in structure takes its own memory..while in case of union, only the largest sized member memory is reserved by the union.
thanked the writer.
Anonymous commented
It can be understood that union manages the memory space but how it is possible means an int will take 2 bytes and a char will take a byte then how would it store both of them in just 2 bytes of memory
Anonymous Profile
Anonymous answered
Union is user defined data types it is similar to structure but differs in
allocated size for it =size of largest member size (save memory) which means that you access one member at a time
Anonymous Profile
Anonymous answered
Union is a user defined data type.
Union test
int add;
char name;
float gom;

Shailesh Par ashar

Answer Question