Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Raw String Literal in C++

  • Difficulty Level : Easy
  • Last Updated : 08 Dec, 2021

A raw string literal is a string in which the escape characters like \n, \t or \”  of C++ are not processed. Hence, this was introduced in C++11, a raw string literal which starts with R”( and ends in )”.

Syntax for Raw string Literal:

R "delimiter( raw_characters )delimiter"

Here, delimiter is optional and it can be a character except the backslash(/), whitespaces( ), and parentheses( () ).

These raw string literals allow a series of characters by writing precisely its contents like raw character sequence. Following is an example of an ordinary string literal and raw string literal:

Ordinary String Literal 


Raw String Literal 


Let’s see an example to see raw string literal in C++: 


// C++ program to demonstrate working of raw string literal
#include <iostream>
using namespace std;
// Driver Code
int main()
    // A Normal string
    string string1 = "Geeks.\nFor.\nGeeks.\n";
    // A Raw string
    string string2 = R"(Geeks.\nFor.\nGeeks.\n)";
    cout << string1 << endl;
    cout << string2 << endl;
    return 0;


This article is contributed by MAZHAR IMAM KHAN. If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!