Difference in using read/write when stream is opened with/without ios::binary mode

后端 未结 2 570
青春惊慌失措
青春惊慌失措 2020-12-06 20:24

In my experiments with the following code snippet, I did not find any particular difference whether i created the streams with/without the ios:binary mode:

i         


        
2条回答
  •  囚心锁ツ
    2020-12-06 21:00

    When you want to write files in binary, with no modifications taking place to your data, specify the ios::binary flag. When you want to write files in text mode, don't specify ios::binary, and you may get things like line ending translation. If you're on a UNIX-like platform, binary and text formats are the same, so you won't see any difference.

提交回复
热议问题