What are the rules for the escape character \
in string literals? Is there a list of all the characters that are escaped?
In particular, when I use \
in a string literal in gedit, and follow it by any three numbers, it colors them differently.
I was trying to create a std::string
constructed from a literal with the character 0
followed by the null character (\0
), followed by the character 0
. However, the syntax highlighting alerted me that maybe this would create something like the character 0
followed by the null character (\00
, aka \0
), which is to say, only two characters.
For the solution to just this one problem, is this the best way to do it:
std::string ("0\0" "0", 3) // String concatenation
And is there some reference for what the escape character does in string literals in general? What is '\a', for instance?