Recently I am working on windows and I found that lot of data structures are defined as struct
with union
as member variables. Example of this would be
union means you can have one of its members as its possible value. In the following example, you see the values for each one of them. But this union can be a member of some other structure, where it is enough to specify only one value- either float or integer not both. Hope this helps.
union {
float u_f;
int u_i;
}var;
var.u_f = 23.5;
printf("value is %f\n", var.u_f);
var.u_i = 5;
printf("value is %d\n", var.u_i)