Hello to all. We say that a union is a way to save some space in structures. I have a question... assuming that we have the following union :
Code:
union {
int i;
double d;
} u;
if the union store an integer and not a double.... what happens with the remaining space?
Another question if I have
Code:
typedef union {
int i;
double d;
} Number ;
int main( void )
{
Number array_numbers[10];
return 0;
}
So array_numbers is an array of unions? We can say that is an array of unions? because it has a similar way with arrays of structures to access an element arrays subscript + (.) operator + name of the member also a union each time it stores only one (integer or double) :
Code:
array_numbers[0].i = 1;
array_numbers[1].d = 1.5; // and so forth....
Thank you in advance.