If you really want to extract the individual bytes first:
unsigned char a = orig & 0xff;
unsigned char b = (orig >> 8) & 0xff;
unsigned char c = (orig >> 16) & 0xff;
unsigned char d = (orig >> 24) & 0xff;
Or:
unsigned char *chars = (unsigned char *)(&orig);
unsigned char a = chars[0];
unsigned char b = chars[1];
unsigned char c = chars[2];
unsigned char d = chars[3];
Or use a union of an unsigned long and four chars:
union charSplitter {
struct {
unsigned char a, b, c, d;
} charValues;
unsigned int intValue;
};
charSplitter splitter;
splitter.intValue = orig;
// splitter.charValues.a will give you first byte etc.
Update: as friol pointed out, solutions 2 and 3 are not endianness-agnostic; which bytes a, b, c and d represent depend on the CPU architecture.