CS 105 (C++)

Discussion 14
C++: Other Things You Should Know


What is endl?

It's a way of adding an end-of-line to output when using <iostream>.  

(Note: The following answers have not been confirmed from an authoritative source, but rather represent the apparent consensus of online commentators.)

What's good about using endl instead of the alternatives?
  1. Platform-independence?

    No, both '\n' and endl are platform-independent when used with <iostream>, ultimately producing the proper character or character sequence for the current operating system.  

  2. Efficiency?

    No, in fact endl is equivalent to '\n' followed by a flush of the output buffer, typically resulting in reduced efficiency.