How to print \n in cout? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 5

How to print \n in cout?

how print "" also?

27th Oct 2017, 3:13 AM
Shubham Sharma
Shubham Sharma - avatar
7 Antworten
+ 10
cout<<"\n"; // new line cout<<"\\n"; // prints \n cout<<"\"\""; // prints "" Btw, \ is the escape character, which lets you prevent the functions that the characters normally represent so you can print them instead.
27th Oct 2017, 3:38 AM
AgentSmith
+ 1
No. Actually @Shubham do not ask to do line break. However, he ask how to print \n in the console
27th Oct 2017, 1:27 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
0
You can even use endl for a next line.
27th Oct 2017, 1:24 PM
Ana Gillani
Ana Gillani - avatar
0
Cout << “whatever you wish to print”<< endl;
27th Oct 2017, 1:25 PM
Ana Gillani
Ana Gillani - avatar
0
\n is one of the escape characters in C++ programming language and you can also use endl for a new line and when you use \n it should be in the ""
28th Oct 2017, 7:44 AM
Beka Dessalegn
Beka Dessalegn - avatar
0
Just writing cout<< “\n “ ;
2nd Nov 2017, 11:44 PM
Asma
Asma  - avatar
0
it cannot be printed as the output it is used only to escape or for the new line
21st Nov 2017, 6:10 PM
CHHOTI UPADHYAY
CHHOTI UPADHYAY - avatar