endl manipulator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

endl manipulator

I read that for a newline I can use the endl manipulator and I know from C that character '\n' also inserts a new line. Is there any difference between them, or '\n' has been kept in order to maintain backward compatibility with C?

19th Aug 2018, 8:53 PM
Charalampos Kontos
Charalampos Kontos - avatar
4 Answers
+ 5
1) this has been asked many times already. please search for it first. 2) endl, I believe, flushes the output. maybe I'm wrong...
19th Aug 2018, 9:59 PM
J.G.
J.G. - avatar
+ 2
Charalampos Kontos you can't decide whether or not to "keep" "\n", it's a standardized general escape character, and it's based on the operating system, not the language
20th Aug 2018, 6:26 AM
hinanawi
hinanawi - avatar
+ 1
endl is used to create the new line.
19th Aug 2018, 9:08 PM
program
program - avatar