I
irwishlaw
After compiling and running the following program
#include <stdio.h>
#include <string.h>
typedef union
{
int a;
char b[2048];
float c;
} Foo, *LPFOO;
static Foo Bloof;
int main(int argc, char *argv[])
{
Bloof.a=1;
printf("% d\n",(int)Bloof.a);
strcpy(Bloof.b,"Hello, World!");
printf("%s\n",Bloof.b);
printf("% d\n",(int)Bloof.a);
Bloof.c=3.14159;
printf("% .7G\n",(float)Bloof.c);
return 0;
}
the results produced are
1
Hello, World!
1819043144
3.14159
After Bloof.b has been made the active member of the union
what is the nature of the value, 1819043144, that the
printf("% d\n",(int)Bloof.a);
produces? Is it a numerical value related to the value, "Hello
World",
of the active union member Bloof.b or an address or just a random
number?
Robert Wishlaw
#include <stdio.h>
#include <string.h>
typedef union
{
int a;
char b[2048];
float c;
} Foo, *LPFOO;
static Foo Bloof;
int main(int argc, char *argv[])
{
Bloof.a=1;
printf("% d\n",(int)Bloof.a);
strcpy(Bloof.b,"Hello, World!");
printf("%s\n",Bloof.b);
printf("% d\n",(int)Bloof.a);
Bloof.c=3.14159;
printf("% .7G\n",(float)Bloof.c);
return 0;
}
the results produced are
1
Hello, World!
1819043144
3.14159
After Bloof.b has been made the active member of the union
what is the nature of the value, 1819043144, that the
printf("% d\n",(int)Bloof.a);
produces? Is it a numerical value related to the value, "Hello
World",
of the active union member Bloof.b or an address or just a random
number?
Robert Wishlaw