I'm attempting to write a program in C that examines bytes in memory and prints their contents. Given a 4-byte unsigned integer, what would a function look like that prints a specific byte of the integer to stdout in hexadecimal? Does printf have some sort of capability like this built-in?
Here's the interface of what I'm looking for.
// number - the integer to be examined
// order - the byte to be examined, with 0 being the lowest-order
// (first) byte and 3 being the highest order (last) byte
void print_byte(unsigned number, unsigned order);
If it's important for the implementation, this would be a little-endian machine.