What is difference between "endl" and "\n"?

:rolleyes:

Is endl and \n is same if NOT please specify what is the difference between both?

  1. In what language?

  2. Different platforms have different line endings....

Macintosh <CR>
DOS/Windows/OS2 <CR>/<LF>
UNIX <LF>

endl is a manipulator in ostream class which when inserted *into an output stream it inserts a new line character and then flushes the stream.
So..that explains what it means when you use just a '\n' or an endl.

I think the result(Next Line) is the same but perhaps the implementation is different.

endl is a platform specific end of line character. If you use /n, it will only put in a line feed. If you use endl, it would use CR on macs, CR/LF on Windows, and LF on unix. Very nice little construct.