Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: What is the R used for in a const char definition?

  1. #1

    What is the R used for in a const char definition?

    All,

    I have working code that creates a web page and displays data via AJAX. No issues but a question?

    in my we page char definition there is and R character. Anyone know what it's used for?


    Code:
    const char PAGE_MAIN[] PROGMEM = R"=====(
    
    <!DOCTYPE html>
    <html lang="en" class="js-focus-visible">
    <title>PATRIOT RACING</title>
    
    
    .. a bunch of stuff in here....
    
    
    </script>
    </body>
    </html>
    
    
    
    )=====";

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,964
    Never used it before, but I believe it stands for RAW
    https://en.cppreference.com/w/cpp/la...string_literal

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,583
    The R allows to assign text "as written", you don't have to care about adding escaped new line codes.

  4. #4
    All thanks for the replies. The R designation is a great way for one to "write at will" when creating huge chars.

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,747
    Quote Originally Posted by KrisKasprzak View Post
    All thanks for the replies. The R designation is a great way for one to "write at will" when creating huge chars.
    I tend to prefer string constant gluing (which unlike R"..." is part of the standard C and C++ languages):

    Code:
    const char message[] = ""
       "This is line1\n"
       "This is line2\n"
       "This is line3\n";

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •