C++11的原始字面量
原始字面量(值)可以直接表示字符串的实际含义,不需要转义和连接。
语法: R"(字符串的内容)"
R"xxx(字符串的内容)xxx"
示例:
#include <iostream> // 包含头文件。
using namespace std; // 指定缺省的命名空间。
int main()
{
// 使用转义的方法
string path = "C:\\Program Files\\Microsoft OneDrive\\tail\\nation";
cout << "path is " << path << endl;
// 使用C++11原始字面量
string path1 = R"abcd(C:\Program Files\Microsoft OneDrive\tail\nation)abcd";
cout << "path1 is " << path1 << endl;
string str = R"(
<no>0001</no>
<name>怡怡子</name>
<yz>666</yz>
<age>24</age>
<weight>48.5</weight>
<height>172</height>)";
cout << str << endl;
}
其他保留字:
关于C/C++中其他数据类型及保留字可以参考我以前的博客
http://t.csdn.cn/J5fi1http://t.csdn.cn/J5fi1