Create string with ESC characters

920 views Asked by At

I can initialise string with escape characer like std:string s="\065" and this creates "A" character. But what if I need ASCI character = 200. std:string s="\200" not working. Why?

2

There are 2 answers

3
marom On BEST ANSWER

"\065" does not create "A" but "5". "\065" is interpreted as an octal number, which is decimal 53, which is character '5'.

std::string s = "\xc8" ; (hex) gives me the character 200.

0
No-Bugs Hare On

Because \065 is actually in octal form; to specify character 200, try \310 or \xc8. And BTW, \065 is not character A but is 5.