Given the following union definition:
typedef union{
int i;
char ch;
float f;}record;
record a;
//a.i = 10;
a.ch = 'A';
//a.f = 10.56;
printf("printing a.i: %p \n", a.i);
printf("printing a.ch: %c \n", a.ch);
printf("printing a.f: %f \n", a.f);
return 0;
I get the following output:
printing a.i: 65
printing a.ch: A
printing a.f: 0.000000
Why does a.i not print 0 (the default value for undefined integers) but instead the ASCII value for 'A'. Does this somehow have access to a.ch??