+ 1

Is there a benefit from endl or /n

what's the difference between the two because they do the same thing?

19th Apr 2017, 7:24 AM
Jamie
3 Respuestas
+ 1
from what I've just read on stack the endl manipulator flushes the stream buffer, the \n doesn't.
19th Apr 2017, 7:43 AM
Jamie
+ 6
using "\n" in your string makes it weird. so endl just prints another "\n" for you without making it weird.
19th Apr 2017, 7:28 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 6
usage of "\n" : cout << "some string\n"; // (weird string / annoying) usage of endl : cout << "some string" << endl; // (better and clean)
19th Apr 2017, 7:32 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar