如何使用cout输出\符号?

Som*_*ser 9 c++

如何使用cout输出\符号?

Dan*_*ite 24

使用两个反斜杠 \\


Tom*_*Tom 23

除了所有正确答案之外,请参阅此内容以获取更多转义字符

\a  Bell (beep)
\b  Backspace
\f  Formfeed
\n  Newline
\r  Return
\t  Tab
\\  Backslash
\'  Single quote
\"  Double quote
\xdd    Hexadecimal representation
\ddd    Octal representation
\?  Question mark ('?')
Run Code Online (Sandbox Code Playgroud)


mch*_*mch 16

'\'字符是C和C++中的转义字符.您可以通过自身转义输出文字'\':

   cout << "This is a backslash: \\";
Run Code Online (Sandbox Code Playgroud)