Changing std::endl to put out CR+LF instead of LF

后端 未结 5 2165
忘了有多久
忘了有多久 2021-02-08 14:09

I\'m writing a program on a Linux platform that is generating text files that will be viewed on, inevitably, a Windows platform.

Right now, passing std::endl

5条回答
  •  既然无缘
    2021-02-08 14:43

    std::endl is basicly:

    std::cout << "\n" << std::flush;
    

    So just use "\r\n" instead and omit the flush. It's faster that way, too!

    From the ostream header file on endl:

    This manipulator is often mistakenly used when a simple newline is desired, leading to poor buffering performance.

提交回复
热议问题