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

后端 未结 5 2180
忘了有多久
忘了有多久 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条回答
  •  猫巷女王i
    2021-02-08 14:42

    Here was my solution to the problem. It's a bit of a mash-up of all the info provided in the answers:

    1. I created a macro in a win_endl.h file for the newline I wanted:

      #define win_endl "\r\n"
      
    2. Then I did a search-and-replace:

      sheepsimulator@sheep\_machine > sed -i 's/std::endl/win_endl' *
      

    And ensured all my files included win_endl.h.

提交回复
热议问题