• ulterno@programming.dev
    link
    fedilink
    English
    arrow-up
    19
    ·
    edit-2
    1 day 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

      • pelya@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        23 hours 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