I have the following union :
union Variant{
char txt[10];
double floating_point;
};
The confusion comes when I try to print sizeof(Variant)
, which outputs 16 bytes.
Why doesn't it output 10 bytes instead of 16 ? if union takes up as much memory as its largest member, it should do max(sizeof(char[10]), sizeof(double))
no ?
Where does the 6 bytes comes from anyway, if in my system a double
takes 8 bytes ?