, , . :
#include<stdio.h>
union test {
int i;
double d;
};
int main()
{
union test obj;
obj.d=15.5;
obj.i=200;
printf("\nValue stored in d is %f",obj.d);
printf("\nValue stored in i is %d",obj.i);
printf("\n size of obj is %d ",sizeof(obj));
obj.d=17.5;
printf("\nValue stored in d is %f",obj.d);
printf("\nValue stored in i is %d",obj.i);
printf("\n size of obj is %d ",sizeof(obj));
obj.i=300;
printf("\nValue stored in d is %f",obj.d);
printf("\nValue stored in i is %d",obj.i);
printf("\n size of obj is %d ",sizeof(obj));
}
:
$ ./main
Value stored in d is 15.500000
Value stored in i is 200
size of obj is 8
Value stored in d is 17.500000
Value stored in i is 0
size of obj is 8
Value stored in d is 17.500000
Value stored in i is 300
size of obj is 8
, 0 ! , (?) .
undefined , , , , , .. ..
Edit:
, - , , ? 200.
, ? , "int", "" , 17.5. . : . "Imreal" .