C++ change newline from CR+LF to LF

前端 未结 2 1376
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 02:10

I am writing code that runs in Windows and outputs a text file that later becomes the input to a program in Linux. This program behaves incorrectly when given files that hav

2条回答
  •  有刺的猬
    2020-12-10 02:34

    OK, so this is probably not what you want to hear, but here's my $0.02 based on my experience with this:

    If you need to pass data between different platforms, in the long run you're probably better off using a format that doesn't care what line breaks look like. If it's text files, users will sometimes mess with them. If by messing the line endings up they cause your application to fail, this is going to be a support intensive application.

    Been there, done that, switched to XML. Made the support guys a lot happier.

提交回复
热议问题