170
you are viewing a single comment's thread
view the rest of the comments
[-] barubary@infosec.exchange 16 points 10 months ago

The same is true of std::endl. std::endl is simply defined as << '\n' << std::flush; nothing more, nothing less. In all cases where endl gives you a "properly translated" newline, so does \n.

[-] SpaceNoodle@lemmy.world 7 points 10 months ago

Ahhh, I see. Looks like the magic happens somewhere further down in iostream.

[-] AnyOldName3@lemmy.world 4 points 10 months ago

It's controlled by whether the stream's opened in text mode or binary mode. On Unix, they're the same, but on Windows, text mode has line ending conversion.

[-] zenforyen@feddit.org 3 points 10 months ago

Yeah it's an artificial dichotomy based on a popular misconception of what std::endl is and how \n is interpreted.

Ultimately it does not ask about line endings, but about flushing, which is a completely orthogonal question.

this post was submitted on 05 Apr 2025
170 points (95.7% liked)

Programmer Humor

40435 readers
23 users here now

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

Rules:

founded 6 years ago
MODERATORS