一、原始字面量
R “xxx(原始字符串)xxx”,其中()两边的字符串可以省略。
#include <iostream>
#include <string>
using namespace std;
int main() {
    string str1 = R"(D:\hello\heheda\test.txt)";
    string str2 = R"(<html>
        <head>
        <title>
        魔卡少女樱
        </title>
        </head>
        <body>
        <p>
        一定没问题的!!!
        </p>
        </body>
        </html>)";
    
    cout << str1 <<endl;
    cout << str2 << endl;
    return 0;
} 

强调一个细节,在R “xxx(raw string)xxx” 中,xxx要配套,原始字符串必须用括号()括起来
#include <iostream>
#include <string>
using namespace std;
int main() {
    //string str3 = R"Sakura(D:\hello\heheda\test.txt)ZhiShi"; //语法错误
    //cout << str3 <<endl;
    string str4 = R"Sakura(D:\hello\heheda\test.txt)Sakura";
    cout << str4 <<endl; //打印内容: D:\hello\heheda\test.txt
    return 0;
}
                


















