this post was submitted on 05 Apr 2025
164 points (96.1% liked)

Programmer Humor

36554 readers
533 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
[–] [email protected] 17 points 2 months ago (17 children)
[–] [email protected] 40 points 2 months 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

[–] [email protected] 2 points 2 months ago (2 children)

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

[–] [email protected] 8 points 2 months ago

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

load more comments (1 replies)
load more comments (1 replies)
load more comments (14 replies)