• Hellfire103@lemmy.caOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      2 months ago

      Instead of this:

      cout << "Hello world.\n";
      

      You can do this:

      cout << "Hello world." << endl;
      
      • Daedskin@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        The fact that you used the namespace for cout but not for endl inordinately bothers me

    • vapeloki@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      std::endl is used in output streams in C++ to end the line, using the os specific line termination sequence, and flush the buffer.

      The later one is a performance issue in many cases, why the use of "\n" is considered preferred

        • ClemaX@lemm.ee
          link
          fedilink
          arrow-up
          1
          ·
          2 months ago

          It is the stream itself that is buffered, so the terminal does not handle the contents until the stream is flushed.