samedi 17 juillet 2021

C++ Here Document has no linefeed character

I am trying to use Here Document in C++ to write a multiline string

const char *inpl = R"EOS(line 1
line 2
line 3
line 4)EOS";

This generates a string like "line 1\nline 2\nline 3\nline 4".

Unfortunately, I am not getting a linefeed character, but instead a character \ followed by letter n. I still works when printing but I can't break on \n character, but instead on "\\n" string.

Is there a way to generate real linefeed characters on linebreaks with Here Document in C++ - preferably at compile time?

Aucun commentaire:

Enregistrer un commentaire