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

Is there a difference between endl and /n ?

.

29th Mar 2018, 6:47 PM
ETHAN AUSTIN
ETHAN AUSTIN - avatar
3 Answers
+ 4
'endl' flushes the buffer also, while '\n' does not.
29th Mar 2018, 6:51 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 2
@Jakob Marley and flushing the buffer is simply to help performance, correct?
29th Mar 2018, 6:52 PM
ETHAN AUSTIN
ETHAN AUSTIN - avatar
+ 2
@Ethan Yes, that's correct. It helps prevent excessive writes by storing it in the buffer until it's flushed.
29th Mar 2018, 7:01 PM
Fata1 Err0r
Fata1 Err0r - avatar