- Why are
\a
and \v
not working?
Because the console you’re using doesn’t support them. The compiler does, and produces the correct character code in the output, but the terminal emulator ignores them.
- Why single quote works without the
\
even though \'
is an escape sequence?
Because it’s unnecessary to escape it in strings, you only need to escape it in a char
literal. Same for \"
for string
literal:
"'"
vs. '\''
'"'
vs. "\""
- Is
\?
an escape sequence? (The link says so but ?
works without the \
)
The link actually says something different:
Note that … \?
specifies a literal question mark in cases where the character sequence would be misinterpreted as a trigraph
It’s only there to avoid ambiguity in cases where the following characters would form a valid trigraph, such as ??=
(which is the trigraph for #
). If you want to use this sequence in a string, you need to escape the first (or second) ?
.