Hi,
I'm writing some codes in C18. I have an unsigned int that I wish to break into two chars. I saw something on union struct for a byte, but I don't know how to change it into int. Could anyone help? Thanks.
I wish I can have a variable, say "Value",
Value = 0x8FFF;
Value.HighByte // gives 0x8F
Value.LowByte // gives 0xFF
or any other way that works?
The code I saw for char, so that we can use something like Flags = 0; to set all to zeros or Flags.Timeout = 1; to set a specific value.
Code:union { struct { unsigned Timeout:1; unsigned None:7; } Bit; unsigned char Byte; } Flags;

Reply With Quote

Just going with what the OP posted, figuring s/he'd just swap the labels if not. Checking the C18 User's Guide confirms it though (page 12).
