如何在cout输出中输出\符号?
使用两个反斜杠 \\
\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 ('?')
'\'字符在C和C++中被视为转义字符。如果想要输出一个 '\' 字符,可以使用双反斜杠来进行转义:
' cout << "This is a backslash: \\";
cout << "\\";
std::cout << '\\';
std::cout << R"(There is no need to escape backslash here \)";
cout << "\\" << endl;
你可以使用除 endl 以外的方式:
cout << "\\ \n";