answersLogoWhite

0

Why is union used in C?

User Avatar

Anonymous

16y ago
Updated: 8/16/2019

Union is used in case of libraries which return assorted data's. for example, say a stack library is present which can return an int or double depending on what is on top of stack.

in such a case, the application layer should be able to receive from library either int or double. so in application layer we use union.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What is structure and union?

Structure is a query that is used in language c++


How do you solve A intersecting B union C?

The answer depends on whether you mean A intersecting (B union C) or (A intersecting B) union C.


What is class union in c language?

A union is often confused with the structure data-type that can contain multiple data items simultaneously. A union can contain only one piece of data and that data may be of any data type.struct foo{int a;long b;float c;char d[80];}my_struct;The structure foo will have space for all the variables.union bar{int a;long b;float c;char d[80];}my_union;The union bar will have 80 bytes assigned to it, 80 being the size of the largest variable (char d[80]). At any given time only one variable can be stored in bar.my_union.a is used to read or write an int.my_union.b is used to read or write a long.my_union.c is used to read or write a float.my_union.d is used to read or write a string.C does not have classes, C++ has class unions (a union used to define a class). A class union is the same as a union in C but gets its name from how it is used.


Is it true that if a union c equals b union c then a equals b?

No- this is not true in general. Counterexample: Let a = {1,2}, b = {1} and c ={2}. a union c = [1,2} and b union c = {1,2} but a does not equal b. The statement be made true by putting additional restrictions on the sets.


What is the complement of the union B and C?

not (b or c) = (not b) and (not c)


What kind of weapons did the union use at the battle Gettysburg?

they used rifles,swords,and cannons the union had less weapons then the north but still won b/c the north surrenderd


Can a union be used in c to convert an integer into a double?

No, but a typecast can: int n; double d; d= (double)n;


Prove if a union c equals b union c and a intersect c equals b intersect c then a equals b?

suppose x is in B. there are two cases you have to consider. 1. x is in A. 2. x is not in A Case 1: x is in A. x is also in B. then x is in A intersection B. Since A intersection B = A intersection C, then this means x is in A intersection C. this implies that x is in C. Case 2: x is not in A. then x is in B. We know that x is in A union B. Since A union B = A union C, this means that x is in A or x is in C. since x is not in A, it follows that x is in C. We have shown that B is a subset of C. To show that C is subset of B, we do the same as above.


What is the venn diagram of a union b union c?

Venn diagram is represented with the help of circles. Union of a, b and c is shown by the three fully shaded somewhat overlapped circles. Result will be the elements that is in all three sets(a,b,c).


Structure and union in c?

Both usable.


Was pickled meat used more for the union or Confederate?

union , both used it mostly union


Example for union in c?

union intlong { int i; long l; long long ll; };