Raw strings

When you use a raw string literal you essentially switch off the meaning of escape characters. Whatever you type into a raw string becomes its content, even if you use whitespace including newlines. The raw string is delimited with R"( and )". That is, the string is between the inner parentheses.

    cout << R"(newline is \n in C++ and "quoted text" use quotes)";

Note that, the () is part of the syntax and is not part of the string. The preceding code prints the following to the console:

    newline is \n in C++ and "quoted text" use quotes

Normally in a string \n is an escaped character and will be translated as a newline, but in a raw string it is not translated and is printed as two characters.

In a normal C++ string, you will ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.