Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!ames!ucbcad!ucbvax!decvax!tektronix!uw-beaver!ssc-vax!shuksan!tahoma!fawcett From: fawcett@tahoma.UUCP Newsgroups: comp.lang.c Subject: c question Message-ID: <131@tahoma.ARPA> Date: Thu, 12-Feb-87 17:17:45 EST Article-I.D.: tahoma.131 Posted: Thu Feb 12 17:17:45 1987 Date-Received: Sun, 15-Feb-87 15:46:18 EST Organization: Boeing Commercial Airplane Co., Seattle, WA Lines: 32 Keywords: char, casting, printf I have come across something that I did not expect to find. I was trying to print out a special character to the terminal and got a response other that what I expected. The code I used was: main() { union { char full_message; int _message; }u; u.full_message = 0xaa; printf("%10x\n", (int)u.full_message); printf("%10x\n", u._message); } What I got when I ran this was: ffffffaa aa000000 I have tried various other methods for doing this to no avail. When I tried to print the number as an integer, it worked as expected. Does anyone know what I am doing wrong, or help me to understand why I got this response. John W. Fawcett Voice: (206) 237-5080 Boeing Commercial Airplane Company UUCP: ..!uw-beaver!ssc-vax!shuksan P.O. Box 3707, M/S 66-04 !tahoma!fawcett Seattle, WA 98124-2207