answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

โˆ™ 2011-10-21 14:31:12
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar

Add your answer:

Earn +20 pts
Q: What are the advantages of using Unions?
Write your answer...
Submit
Sign up for more answers

Registered users can ask questions, leave comments, and earn points for submitting new answers.

Already have an account? Log in

Related questions

What are the advantages and disadvantages of wokers being in a trade union?

Unions provide strength. Unions provide support. Unions protect.


What are the advantages of trade unions?

oldest man om earth


What are the advantages and disadvantages of using?

There are no advantages of using.


What were the unions advantages in the civil war?

Britain supplied them with weapons. And they won!


What are the advantages of using ict for a leaflet?

advantages of using ICT


What are the advantages of using Unions in a structure in C?

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.


What are the advantages of using the Internet for an organization?

What are the advantages of using the Internet for an organisation?


What are the advantages of using unions labor?

Union labor is usually a group with a low turnover. One advantage of a low turnover is that the labor force is better paid and more motivated to do a good job.


What are the advantages micrometer?

"What is the advantages of using micrometer?


What are the advantages of using a electronic diary?

What are all the advantages and disadvantages of using an electronic dairy?


Advantages dianvantages of using electronic marketing?

advantages dianvantages of using electornic marketing.


What are the advantages of non-union workplaces?

advantages of not being in a union is that you get paid way better and you dont have to pay unions dues. you have individualism also.


What are Advantages of using a Grinding machine?

Nothing advantages


What are the Advantages using HTML to create webpages?

What are the Advantages using HTML to create web pages?"


Some of the advantages of using word to convey information?

Some of the advantages of using word to convey information


What are the advantages of using symbols in circuit diagram?

The advantages are the same as using symbols in writing to represent the words.


What are the advantages and disadvantages of using artificial insulin?

the advantages and disadvantages of using artificial insulin are... where am i ? whats going on? who are you?


What are the advantages of opera browsers when using the internet?

advantages of opera


What are the advantages of instrument transformer?

what are the advantages of using instrument tranformers


Advantages and disadvantages of using alkenes?

the advantages of alkenes is that they are alkenes.


What is the advantages of using maximum power transfer theorm?

advantages


On mobiles advantages and disadvantages in Hindi?

advantages of using mobile


Advantages of a franking machine?

It is fast using


Advantage by using handphone?

what is advantages of using handphones????


What are the advantages of using HTML?

The advantages are that's it's extremely easy to learn, and you can create your own websites using it.