this post was submitted on 05 Apr 2025
159 points (94.4% liked)

Programmer Humor

35056 readers
133 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] unlawfulbooger@lemmy.blahaj.zone 17 points 1 week ago (17 children)
[–] vapeloki@lemmy.world 40 points 1 week ago (3 children)

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 preferred

[–] xigoi 2 points 1 week ago (2 children)

Don’t most terminals flush the buffer on newline anyway?

[–] ClemaX@lemm.ee 8 points 1 week ago

It is the stream itself that is buffered, so the terminal does not handle the contents until the stream is flushed.

[–] vapeloki@lemmy.world 2 points 1 week ago

Maybe, but there is the internal buffer. Also, most I/O happens in files not consoles

load more comments (13 replies)