what does std::endl represent exactly on each platform?

后端 未结 5 1260
孤独总比滥情好
孤独总比滥情好 2021-01-11 12:01

Thinking about UNIX, Windows and Mac and an output stream (both binary and text),

What does std::endl represent, i.e. ,

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 12:50

    Use stream << "\r\n" (and open the stream in binary mode). stream << std::endl; is equivalent to stream << "\n" << flush;. The "\n" might be converted to a "\r\n" if the code runs on Windows, but you can't count on it -- at least one Windows compiler converts it to "\n\r". On a Mac, it's likely to be converted to "\r" and on Unix/Linux and most similar systems, it'll be left as just a "\n".

提交回复
热议问题