This question already has answers here:
What is the C++ equivalent of the C# @ symbol prefixing strings?

(3个答案)


7年前关闭。




在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)";

关于c++ - 在c++(或c++ 11)中是否有与C#中的@等效的东西?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20508271/

10-11 22:38
查看更多