+ 1

Difference between \n and endl.

I dont seem to understand the difference between /n and endl,in the beginning of sololearn c++ tutorials,They use endl,But in the textbook I have they use \n. What is the difference between them?Help of any sort is appreciated.Thanks for reading.

17th Jan 2018, 2:38 PM
Sangam Swadi K
Sangam Swadi K - avatar
1 Respuesta
+ 3
Yes, they're different. "\n" is just a string of length 1 that gets appended to stdout. std::endl, instead, is an object that will cause to append the newline character ("\n") AND to flush stdout buffer. For this reason it will take more processing -peoro at stackoverflow.com
17th Jan 2018, 2:52 PM
Jonas Schröter
Jonas Schröter - avatar