what are the advantages & disadvantages of unions?

Answer Posted / vishnu nayak

Union occupy same memory area for different members in a
union.
Same are is allocated for different data types of the
members of union
eg:
union
{
int a;
char c;
float f;
}temp;
Size of Float will be size of union.
same memory is used for char and int as well.
Advantages: Memory consumption is less.
Disadvanteges: if one of the member variable is updated the
it will be reflected in the remaining 2 variables.

Is This Answer Correct ?    62 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the value of h?

597


How to set file pointer to beginning c?

674


Why do we use c for the speed of light?

610


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1415


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

1630






What is formal argument?

654


Where are some collections of useful code fragments and examples?

721


Describe how arrays can be passed to a user defined function

788


What is the purpose of clrscr () printf () and getch ()?

605


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1667


What are different types of variables in c?

573


What is variable declaration and definition in c?

505


Explain 'bit masking'?

659


What is structure in c definition?

578


Write a program to show the change in position of a cursor using c

585