The basic advantage is that union will use the memory space of the datatype which has the highest memory …. hence memory consumption will be less…But when u use structure the total memory will be the sum of the memory of all datatypes.. ie. (higher memory allocation)Disadvantage is that…..
Read moreCan bit field used in union?
Bit fields CANNOT be used in union .
Read moreWhat is bit field with example in C?
Declaring Bit FIelds Variables that are defined using a predefined width or size are called bit fields. This bit field can leave more than a single bit. The format and syntax of bit-field declaration inside a structure is something like this: struct { data – type[nameofmember]: width_of_Bit – field; };
Read moreCan bit field used in union?
Bit fields CANNOT be used in union .
Read moreDoes C have bit fields?
In C, we can specify size (in bits) of structure and union members . The idea is to use memory efficiently when we know that the value of a field or group of fields will never exceed a limit or is within a small range.10 Şub 2022
Read moreWhy union is better than structure in C?
Advantages of Union Union takes less memory space as compared to the structure . Only the largest size data member can be directly accessed while using a union. It is used when you want to use less (same) memory for different data members.
Read moreWhy union is better than structure in C?
Advantages of Union Union takes less memory space as compared to the structure . Only the largest size data member can be directly accessed while using a union. It is used when you want to use less (same) memory for different data members.
Read more