Is there any difference between \n and endl ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Is there any difference between \n and endl ?

24th Oct 2016, 4:12 PM
Kumar Ankush
Kumar Ankush - avatar
6 Answers
+ 8
Yes, there is. While std::cout << "\n" only adds the newline character to the standard output stream, std::endl also flushes the stream.
24th Oct 2016, 9:54 PM
Stefan
Stefan - avatar
+ 3
simple terms: /n is used to end a line within a quote, whereas endl requires you to end quotes before using it. for an example: cout>>"hello my name is /n sally"; will create the new line within the quote, whereas cout>>"hello my name is">>endl>>"sally"; is a bit more typing. hope this helps! :D
2nd Nov 2016, 8:17 PM
Demiano DeBella
Demiano DeBella - avatar
0
\n is alternative method of endl..only difference is /n is use for every word in new line ...
25th Oct 2016, 9:42 AM
preeto kashyap
preeto kashyap - avatar
0
\n for new line and endl is used to end the line I.e you cannot add anything on that line apart from your input data
30th Oct 2016, 10:30 PM
Koul Neville
Koul Neville - avatar
0
endl basically ends a line nd further starts new line like we apply full stop in eng nd start next line ..... whereas \n is to start from new line basically they r same but endl terminates nd start whereas \n just starts
22nd Dec 2016, 2:35 PM
sebani
- 1
я русский
8th Nov 2016, 6:29 PM
BORIS LIS1
BORIS LIS1 - avatar