Hellfire103@lemmy.ca to Programmer Humor@lemmy.mlEnglish · 22 days agoDoes this exist anywhere outside of C++?lemmy.mlimagemessage-square23fedilinkarrow-up13arrow-down10cross-posted to: programmer_humor@programming.dev
arrow-up13arrow-down1imageDoes this exist anywhere outside of C++?lemmy.mlHellfire103@lemmy.ca to Programmer Humor@lemmy.mlEnglish · 22 days agomessage-square23fedilinkcross-posted to: programmer_humor@programming.dev
minus-squareunlawfulbooger@lemmy.blahaj.zonelinkfedilinkarrow-up0·22 days agoWhat the heck is endl???
minus-squareHellfire103@lemmy.caOPlinkfedilinkEnglisharrow-up0·edit-222 days agoInstead of this: cout << "Hello world.\n"; You can do this: cout << "Hello world." << endl;
minus-squareDaedskin@lemm.eelinkfedilinkarrow-up1·21 days agoThe fact that you used the namespace for cout but not for endl inordinately bothers me
minus-squarevapeloki@lemmy.worldlinkfedilinkarrow-up0·22 days agostd::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 preferred
minus-squarexigoi@lemmy.sdf.orglinkfedilinkEnglisharrow-up0·22 days agoDon’t most terminals flush the buffer on newline anyway?
minus-squareClemaX@lemm.eelinkfedilinkarrow-up1·22 days agoIt is the stream itself that is buffered, so the terminal does not handle the contents until the stream is flushed.
What the heck is endl???
Instead of this:
You can do this:
The fact that you used the namespace for
cout
but not forendl
inordinately bothers mestd::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 preferredDon’t most terminals flush the buffer on newline anyway?
It is the stream itself that is buffered, so the terminal does not handle the contents until the stream is flushed.