cm0002@lemmy.world to Programmer Humor@programming.dev · 18 days agoDoes this exist anywhere outside of C++?lemmy.mlimagemessage-square48fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageDoes this exist anywhere outside of C++?lemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 18 days agomessage-square48fedilink
minus-squareulterno@programming.devlinkfedilinkEnglisharrow-up0·18 days agoSimple. \n when you just want a newline. println 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.
minus-squareembed_me@programming.devlinkfedilinkarrow-up0·17 days agoI only program in C. I was under the assumption that \n also flushes
minus-squareulterno@programming.devlinkfedilinkEnglisharrow-up0·17 days agoI remember having to fflush a couple of times.
minus-squarepelya@lemmy.worldlinkfedilinkarrow-up0·edit-217 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
Simple.
\n
when you just want a newline.println
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.
I only program in C. I was under the assumption that \n also flushes
I remember having to
fflush
a couple of times.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