C++11 R字符串

阅读 53

2022-01-10

原始字面量

在 C++11 中添加了定义原始字符串的字面量,定义方式为:R “xxx(原始字符串)xxx” 其中 () 两边的字符串可以省略。原始字面量 R 可以直接表示字符串的实际含义,而不需要额外对字符串做转义或连接等操作。

#include <iostream>
using namespace std;
int main()
{
	const char* s1 = R"(Hello\\World)";
	cout << s1 << endl;
	const char* s2 = "Hello\\World";
	cout << s2 << endl;
	return 0;
}

在这里插入图片描述

精彩评论(0)

0 0 举报