you are viewing a single comment's thread
view the rest of the comments
[–] 20 points 1 year ago* (last edited 1 year ago) (1 child)

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

  • source
  • hideshow 2 child comments
  • [–] 5 points 1 year ago (2 children)

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

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 1 year 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

  • source
  • parent