cm0002@lemmy.world to Programmer Humor@programming.dev · 3 days agoDoes this exist anywhere outside of C++?lemmy.mlexternal-linkmessage-square58fedilinkarrow-up1163arrow-down122cross-posted to: programmerhumor@lemmy.ml
arrow-up1141arrow-down1external-linkDoes this exist anywhere outside of C++?lemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 3 days agomessage-square58fedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareulterno@programming.devlinkfedilinkEnglisharrow-up19·edit-22 days agoSimple. \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
minus-squareembed_me@programming.devlinkfedilinkarrow-up5·2 days agoI only program in C. I was under the assumption that \n also flushes
minus-squarepelya@lemmy.worldlinkfedilinkarrow-up3·edit-22 days agoIt 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
minus-squareulterno@programming.devlinkfedilinkEnglisharrow-up2·2 days agoI remember having to fflush a couple of times.
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 ofendl
somehow. Guess I need more downtimeI only program in C. I was under the assumption that \n also flushes
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
I remember having to
fflush
a couple of times.