On Fri, 5 Apr 2002, Mike Mansheim wrote: > Because I'm not a C expert, but this got me to look at it (even though > I only have a Herbert Schildt book to look at). I didn't see a way to > access the other members of the union other than using an array, which > makes the dot references cumbersome. So I used #defines to make those > look better, and ended up with: Try this: #include union lo_hi { unsigned int i; struct { unsigned char l; unsigned char h; } b; }; typedef union lo_hi lo_hi; #define LO_BYTE(x) ( ((lo_hi)(x)).b.l) #define HI_BYTE(x) ( ((lo_hi)(x)).b.h) unsigned int evt_length; int main(int argc, char **argv) { evt_length = 0x1234; printf(" int 0x%02x, low byte 0x%02x, high byte 0x%02x\n", evt_length, LO_BYTE(evt_length), HI_BYTE(evt_length)); return 0; } Scott -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body