I want to take the value stored in a 32 bit unsigned int, put it into four chars and then store the integer value of each of these chars in a string.
I think the first part goes like this:
char a = orig << 8; char b = orig << 8; char c = orig << 8; char d = orig << 8;
If you really want to extract the individual bytes first:
Or:
Or use a union of an unsigned long and four chars:
Update: as friol pointed out, solutions 2 and 3 are not endianness-agnostic; which bytes
a,b,canddrepresent depend on the CPU architecture.