To do this manually, the easiest way is to display nybbles tables in ASCII:
static const char nybble_chars[] = "0123456789ABCDEF";
Then convert the byte to 2 hexadecimal characters - if it unsigned charis the best representation for the byte, but does not make any assumptions about its size - extract each nybble and get a char for it:
void get_byte_hex( unsigned char b, char *ch1, char *ch2 ) {
*ch1 = nybble_chars[ ( b >> 4 ) & 0x0F ];
*ch2 = nybble_chars[ b & 0x0F ];
}
.
please delete me