I\'m writing a C/C++ program that involves putting a hex representation of a number into a string and I\'m confused as to how \\x works. I\'ve seen examples wh
When you use the escape sequence \x inside a string the data following the \x is actually stored in it's binary representation.
So the string "ABC" is equivalent to the string "\x414243"
If you want to emit hexadecimal values in display-character form, you'll want to use the %x or %X format specifier character:
printf("%X%X%X", 'A', 'B', 'C'); // emits "414243"
See Section 1.2.6 and Section 1.2.7 of the C Library Reference Guide
Hope that explanation helps.