char text1[50] = "\aHello,\n\tWorld! Mistakee\b was \"Extra 'e'\"!\n"
would \a or \n be treated as a single character, and if so, then how does the compiler know that the backslash and the 'a' are two different characters?
The reason why I ask is because I am looking at one of the examples from exercise and in the switch statement, it seems to treat special characters like \n as a single character:
The \ character marks the start of an "escape sequence". This lets the compiler know that the next character or group of characters marks the start of a special code.
\n = newline
\r = carriage return
\x53 = ASCII code 0x53 (ie: a capital 'S')
etc
etc
The escape character also lets you put things in a string literal that you normally couldn't... like a quotation mark:
\" = quotation mark
\\ = '\' character
1 2 3 4
std::string foo = "Joe said "Hi""; // <- this won't work because C++ thinks the quotes
// mark the end of the string
std::string foo = "Joe said \"Hi\""; // <- this will work because the quotes are escaped
*Edit
So as an answer to your question, Yes it is a single character. You can use escape sequence on any character. Say you want letter 'K' another way would be '\113'