unions conserves memory space..The amount of space allocated for union is based on the member which requires largest memory space...so unions are useful for applications involving number of variables,where values need not be assigned to all elements at one time.
AnswerIts used to save on space.For eg. you have a struct for storing information about insurance policy holders. But there are three types of insurances: Home, Life, Auto. Now basic details about policyholders such as name, address, etc is the same no matter what insurance you are talking about. But certain details are different. So by making a union policyinfo in this struct which is a diff internal struct for each of these policies you can save on space. When you are entering info about a Home policy, then you use the common fields AND only the struct for home insurance. You do not even fill/care about the other structs in the union. Upon storage only the Home struct will be stored, and the others will be discarded. Keep a variable in the main struct which indicates the type of insurance policy and so, which of the structs in the union you want to use. This way, you have just one big structure for all policyholders, instead of three -- it provides a common interface and saves on storage.
===============
The above answers are not correct. Unions do not save memory or storage space. Unions allow the same area of memory to be accessed as different data types. The insurance example above would not work.
<><><>
Unions are useful (often in embedded programming) when it is needed to refer to a data item as two or more different types: e.g. it may be used as an integer for math, but an array of bytes for a serial transmission or a checksum calculation.
For memory preservation, since the space allocated for the union is as big as its biggest member.
The advantages of desalination is that you are not going to run out of water if you are using a water source like the ocean.
what are the advantages and disadvantages of refrigeration
what are advantages and disadvantages of shapper machine
yighjg
It makes a gas
Unions provide strength. Unions provide support. Unions protect.
It offers advantages such as greater negotiating power with labor unions.
In case of structure each variables have their own storage location whereas for unions all the variables share a common memory location. In structure all the variables can be handled at a time but for union only a member can be handled at a time.
advantages of using ICT
what is the advantages of using a sat nav.
what are the advantages and disadvantages of using a heligimbal
"What is the advantages of using micrometer?
"The advantages of using a stability ball as a chair
What are all the advantages and disadvantages of using an electronic dairy?
Nothing advantages
what are the advantages of using instrument tranformers
noting advantages