How do you print "\n"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do you print "\n"?

If I wanted to print "\n" as it is so that it displays those characters, instead of ending my line there, how do I include it within the quotation marks when the compiler doesn't identify it as a part of my string?

4th May 2019, 10:41 PM
Jane Doe
Jane Doe - avatar
3 Answers
+ 3
"\\n"
4th May 2019, 10:47 PM
Lemuel
Lemuel - avatar
+ 5
Just use "\\n" instead of "\n". Another '\' in front of \ means that it isn't a special character representation because "\\" = string('\'). You can use it with every '\'.
5th May 2019, 12:21 AM
Mayank
Mayank - avatar
0
R"(\n)"
23rd Sep 2019, 9:46 PM
李志玉