$ cat aa.c #include <stdio.h> int main () { char c = 'A'; char hexchars[] = "0123456789ABCDEF"; char c_as_hex[] = {hexchars[c >> 4], hexchars[c & 0xF], '\0'}; printf("%s\n", c_as_hex); return 0; } $ gcc -o aa aa.c $ ./aa 41
[download]