Ignore C ++ escape sequence

I tried to find google but could not find the answer, can anyone tell me how to ignore the escape character stored in the string. I use an array that contains different characters, such as

string str[]={"| | / / ||","| |/ / ||", "| | ( \ \ \ \`_."}

Error message from compiler:

"unknown escape sequence" in

+3
source share
2 answers

As @Zac already pointed out, you can avoid \to avoid the problem. Another way you can find a cleaner 1 is to use string string literals:

string str[]={R"(| | / / ||)",R"(| |/ / ||)", R"(| | ( \ \ \ \`_.)"};

, : ), , , - :

string s = R"!(This (might be) an MS-DOS path\to\a\string)!";

: , : , . . , , , , , . ( ) , - , , , .


1. : ++ 11, , , .

+9

\. :

string str[]={"| | / / ||", "| |/ / ||", "| | ( \\ \\ \\ \\`_."};

++ ( langauges C) \ escape- (, \r, \n, \t ..). "\" , : \\.

+5

All Articles