+ 2

Difference between "\n" and "endl"!?

I want to know where is the difference between this two cause they work exactly the same.

23rd Feb 2018, 1:43 PM
Ayman Khan
Ayman Khan - avatar
7 Réponses
+ 18
Both works as a enter key... But endl flushes the output buffer and \n doesn't ... In short endl is slower than \n... so if u r writing a very lengthy code of million lines use \n instead of endl...
23rd Feb 2018, 2:10 PM
🌛DT🌜
🌛DT🌜 - avatar
+ 8
no difference, they do exactly same thing...
23rd Feb 2018, 1:52 PM
Vukan
Vukan - avatar
+ 1
if they do the same thing then why to create more X)
23rd Feb 2018, 1:54 PM
Ayman Khan
Ayman Khan - avatar
+ 1
they both are same
24th Feb 2018, 5:37 PM
SIDDHU SONAR
SIDDHU SONAR - avatar
0
\n is used in c and endl is used in c++
24th Feb 2018, 7:34 AM
Jurat Ômārï
Jurat Ômārï - avatar
0
both used for new line(enter key). but in c,there is \n and in c++,endl.
24th Feb 2018, 12:32 PM
Udit
0
endl work as "the line is end" & \n work as a "new line"
25th Feb 2018, 8:15 AM
Urvashi Bhansali
Urvashi Bhansali - avatar