我将buffer去处理后以二进制形式存放入文件。可发现写入一个0x0a后再次打开文件时发现变成了0x0d,0x0a。这个0x0d是哪儿来的,平台是windows xp(e), 工具vc6.0

解决方案 »

  1.   

    是不是用的二进制形式哦。我上次用文本格式写进去就会这样。FILE* f=fopen(szName,"ab")这样应该不会
      

  2.   

    0x0d,0x0a 对应ascii码的回车,换行
      

  3.   

    以二进制方式读写文件就不会出现这种问题,以文本方式读写文件时,API会自动转换一些特殊含义的字符。二进制方式->"b"
      

  4.   

    "r" open text file for reading 
    "w" create text file for writing; discard previous contents if any 
    "a" append; open or create text file for writing at end of file 
    "r+" open text file for update (i.e., reading and writing) 
    "w+" create text file for update, discard previous contents if any 
    "a+" append; open or create text file for update, writing at end  我用的是rb