我需要在 C++ 中执行以下 C# 代码(如果可能)。我必须构造一个长字符串,里面有很多奇怪的引号和其他东西。
const String _literal = @"I can use "quotes" inside here";
最佳答案
这在 C++03(当前标准)中不可用。
这是 C++0x 草案标准的一部分,但目前还没有现成的。
现在,您只需明确引用它:
const std::string _literal = "I have to escape my quotes in \"C++03\"";
一旦 C++0x 成为现实,您就可以编写:
const std::string _literal = R"(but "C++0x" has raw string literals)";
当你需要 )"
在你的文字中:
const std::string _literal = R"DELIM(more "(raw string)" fun)DELIM";
关于c++ - 字符串文字 C++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2597322/