Possible Duplicate:
what does std::endl represent exactly on each platform?
I'm trying to figure out if std::endl returns \r\n, \n, or \r depending on the platform, or if it sticks with one all the time.
Possible Duplicate:
what does std::endl represent exactly on each platform?
I'm trying to figure out if std::endl returns \r\n, \n, or \r depending on the platform, or if it sticks with one all the time.
std::endl is just a "shorthand" for '\n' << std::flush. It is not platform dependent.
However, '\n' itself is handled differently on each platform and gets replaced with '\r\n', '\n', or '\r' (or something like that) if the stream is opened in text mode.
'\n' Outputs a newline (in the appropriate platform-specific representation, so it generates a "\r\n" on Windows). std::endl does the same and flushes it.
Use '\n' instead of std::endl; when trying to output a newline, but use std::endl when trying to flush it. Unnecessary flushing decreases the performance of your application, for all we know file i/o is one of the slowest operations besides user i/o.