answersLogoWhite

0

The total number of bytes allocated to the union will be the same number as would have been allocated if instead of the union was declared the largest member of the union. For example, if you declared: union myUnion { char c; int i; double d; } u;, then the space allocated to u will be the size of a double.

User Avatar

Wiki User

17y ago

What else can I help you with?

Related Questions

Why do you go for structure and union?

Structure and union are a form of encapsulating similar data elements.Structure:Whenever a structure is declared, then space equal to the total size of the elements defined inside the structure is allocated. Hence each individual element has its own memory space. Hence structures are commonly used when there is usage for more than one element declared inside the struct at a time.Union:Whenever an union is declared, then space equal to the size of the maximum element defined inside the union is allocated. Hence the individual elements share a common memory space. Hence union is commonly used when there is usage for only one element declared inside the union at a time.


How did the people in the Soviet Union get jobs?

From the government. (they were allocated)


How will the memory be allocated in unions when 2 data types say int n float are declared?

A "Union" is a data type whose size will be determined by the member with largest size inside the union. So: union MyUnion{ int MyInteger; float MyFloat; }; MyUnion's size will be MyFloat's size, because that float is the largest sized member.


Difference between array and union?

All the members of the structure can be accessed at once,where as in an union only one member can be used at a time. Another important difference is in the size allocated to a structure and an union. for eg: struct example { int integer; float floating_numbers; } the size allocated here is sizeof(int)+sizeof(float); where as in an union union example { int integer; float floating_numbers; } size allocated is the size of the highest member. so size is=sizeof(float);


How can the union member share memory?

All union members are allocated the same memory address. The amount of memory allocated is determined by the largest member of the union. Only one value can be stored in a union. If we change the value of any one member, we change the value for all members. The member type determines how the current value is interpreted.


What number was pen declared as a state in the union?

Second.


What is an union in C language?

A "union declaration" specifies a set of variable values and, optionally, a tag naming the union. The variable values are called "members" of the union and can have different types. Unions are similar to "variant records" in other languages.


What happened to Soviet Union in 1991?

15 republics declared independence and Soviet Union no longer existed.


Which Library is declared on 2nd February 1953 the union Education minister declared open to all?

National Library, Culcutta


Who declared war on japan at end of war?

Soviet Union (Russia).


Who declared South Carolina's secession from the Union illegal?

President Buchanan


What year was West Virginia build?

It was declared a state of the Union in 1863.