What's the difference between endl and \n | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the difference between endl and \n

23rd Aug 2017, 1:25 PM
Shiva Teja
Shiva Teja - avatar
2 Answers
+ 11
endl flushes the output stream, while \n is simply a newline character.
23rd Aug 2017, 1:27 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Functionality wise, nothing. One you use inside of the string, the other outside of it. Forgot about the flush call. Aside from pushing \n, endl also flushes. Hatsy right about that part.
23rd Aug 2017, 1:34 PM
AgentSmith