在C#中,我们可以定义一个复杂的字符串@:在C++(或C++ 11)中是否有类似于c#的东西?
string str = @"This is the first line.\r\nThis is still the first line";
怎么样在C++?如果我们有这样的东西,我们不需要为所有特殊字符使用转换符号'\'。
在C#中,我们可以定义一个复杂的字符串@:在C++(或C++ 11)中是否有类似于c#的东西?
string str = @"This is the first line.\r\nThis is still the first line";
怎么样在C++?如果我们有这样的东西,我们不需要为所有特殊字符使用转换符号'\'。
在C++ 11头(只),你可以使用原始字符串字面量:
std::string str = R"(This is the first line.\r\nThis is still the first line)";
你错过了括号。 – chris
@chris谢谢。 – polkadotcadaver
是,原始字符串字面量。 http://stackoverflow.com/questions/10501599/define-stdstring-in-c-without-escape-characters/10501649#10501649 – chris