【问题标题】:Is there something equivelant in c++(or c++11) for @ like in c#? [duplicate]在c++(或c++11)中是否有类似c#中的@的等价物? [复制]
【发布时间】:2013-12-11 00:31:07
【问题描述】:

在C#中,我们可以用@定义一个复杂的字符串:

string str = @"This is the first line.\r\nThis is still the first line";

在 C++ 中怎么样?如果我们有这样的东西,我们不需要对所有特殊字符使用转换符号'\'。

【问题讨论】:

标签: c++


【解决方案1】:

在 C++11(仅)中,您可以使用原始字符串文字:

std::string str = R"(This is the first line.\r\nThis is still the first line)";

【讨论】:

  • 你缺少括号。
猜你喜欢
  • 2012-04-29
  • 2021-05-14
  • 2021-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-29
相关资源
最近更新 更多