葱葱那年丶 2020-09-22 16:28 采纳率: 100%
浏览 195
已采纳

const char *s = R"(apple)"; 是什么意思?

const char *s = R"(apple)";

R"()" 是什么语法?

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main()
{
    const char* s = R"(apple)";
    printf("%s\n", s);

    system("pause");
    return 0;
}

  • 写回答

5条回答

  • a569528788 2020-09-22 17:44
    关注

    用来避免转义字符
    // Raw string literals containing unescaped \ and "
    auto R0 = R"("Hello \ world")"; // const char*
    auto R1 = u8R"("Hello \ world")"; // const char*, encoded as UTF-8
    auto R2 = LR"("Hello \ world")"; // const wchar_t*
    auto R3 = uR"("Hello \ world")"; // const char16_t*, encoded as UTF-16
    auto R4 = UR"("Hello \ world")"; // const char32_t*, encoded as UTF-32

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?