If I’m writing C++, I’m usually optimizing for portability over performance, in which case I would prefer std::endl as it would yield the best results regardless of platform; it also keeps the end-of-line character out of other strings, making code just a little cleaner.
\n is for when I’m done pretending that anything that isn’t Unix-like is OK, and I’m counting the cycles of every branch instruction.
\n, because I ordered a newline, not a flush.
What the heck is endl???
std::endl
is used in output streams in C++ to end the line, using the os specific line termination sequence, and flush the buffer.The later one is a performance issue in many cases, why the use of
"\n"
is considered preferredInstead of this:
cout << "Hello world.\n";
You can do this:
cout << "Hello world." << endl;
The fact that you used the namespace for
cout
but not forendl
inordinately bothers me
Boy am I glad I don’t do C++ anymore. That string handling with the overloaded bitshift operator was wild.
Alternatively:
https://en.cppreference.com/w/cpp/io/manip/endl
p.s. The site isn’t entirely mobile friendly
(I’m a cppref lover tbh)
From memory it’s a way to declare a line ending after your string.
God bless your soul.
#define endl “\n”
\r\n gang
Get out
Yeah
\r
gang4lyfe
Are you a modem by any chance?
No, I’m a teapot
I’m on side
\PHP_EOL
I like that you added the absolute namespace identifier or whatever its called
I don’t always namespace but when I do I fully qualify.
vbCrLf
Endl is faster to type
Well, Java has System.lineSeparator so, maybe no?