How does "\x" work in a String?

c, c++, hex

Solution

From the C99 standard (6.4.4.4):

Each octal or hexadecimal escape sequence is the longest sequence of characters that can constitute the escape sequence.

Problem

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 where people have written things such as "\xb2". In this case, how does the program know if you want the hex of b followed by the number 2 or if you want the hex of b2? Additionally, when it stores this into memeory does it save the "\x" characters or does it just save the hex representation?

Original source