144
you are viewing a single comment's thread
view the rest of the comments
[-] ulterno@programming.dev 20 points 3 weeks ago* (last edited 3 weeks ago)

Simple. \n when you just want a newline.
endl when you need to flush at the moment.

Useful in case you are printing a debug output right before some function that might do bed stuff to buffers.


Edit: I wrote println instead of endl somehow. Guess I need more downtime

[-] embed_me@programming.dev 5 points 3 weeks ago

I only program in C. I was under the assumption that \n also flushes

[-] pelya@lemmy.world 3 points 3 weeks ago* (last edited 3 weeks ago)

It depends on whether you are printing to a terminal or to a file (and yes the terminal is also a file), and even then you can control the flushing behaviour using something like unbuffer

[-] ulterno@programming.dev 2 points 3 weeks ago

I remember having to fflush a couple of times.

this post was submitted on 05 Apr 2025
144 points (87.9% liked)

Programmer Humor

22854 readers
309 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS