我要从 C# 转到 C++。我有一个带有很多反斜杠的字符串,我想将该字符串作为原始文本读取。 C++ 有类似 C# 的“at string”吗?例如:
string s = @"\\Some\Path";
在我使用的 C++ 文件中:
#include <string>
最佳答案
您可以使用原始字符串文字:
std::string s = R"(\Some\Path)";
此功能在 C++11 中可用。
请注意,对于文件系统路径,您可以使用正斜杠:
std::string s = "/Some/Path";
关于c# - 在 C++ 中创建原始文本字符串,类似于 C#'s "@string",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18151117/