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

What's the difference between endl & \n ?

2nd Dec 2016, 1:53 PM
Nikhil Sharma
Nikhil Sharma - avatar
3 Answers
+ 3
'endl' means the end of the system of a cout. '\n' write the next string/input on a new line(aka below the previous line) in the same system of a cout
2nd Dec 2016, 2:01 PM
Wen Qin
Wen Qin - avatar
+ 1
'\n' is just one special char (new line or line feed). endl is new line, but depending on the system it may be only line feed '\n' or CR ('\r') and LF ('\n')
2nd Dec 2016, 3:41 PM
px16
px16 - avatar
0
ending your cout statements with endl will flush the buffer and prevent weird output errors.
2nd Dec 2016, 3:31 PM
Adam Hurd
Adam Hurd - avatar