C struct print, decode this code?

Posted by pauliwago on Stack Overflow See other posts from Stack Overflow or by pauliwago
Published on 2012-10-31T06:24:50Z Indexed on 2012/10/31 11:00 UTC
Read the original article Hit count: 182

Filed under:
|

I am in the process of studying for a test, and I'm trying to work through some practice problems. I've been working on this a while now..but can't figure it out. Please take a look at the code fragment:

 union {
   int i;
   short x;
   unsigned short u;
   float f;
 } testout;
 testout.i=0xC0208000;

Before I ask the question, can someone please explain to me how the above code works?? My guess is that testout.i=0xC0208000 puts either an int, short, unsigned short, or float and puts the result in that address. (?)

The question is what prints out if we write printf("%d", testout.x)? I know we should expect digits....but I have no idea where they are getting the digits from....there is no output.

Any explanation would be greatly appreciated. Thanks!

© Stack Overflow or respective owner

Related posts about c

    Related posts about address