fopen中r+和w+的区别是什么?

2025-03-12 20:09:37
推荐回答(1个)
回答1:

  1. r+: Open for reading and writing.  The stream is positioned  at  the beginning of the file.

  2. w+:Open for reading and writing.  The file is created  if  it  does not  exist, otherwise it is truncated.  The stream is positioned at the beginning of the file.

  3. r+具有读写属性,从文件头开始写,保留原文件中没有被覆盖的内容;

  4. w+具有读写属性,写的时候如果文件存在,会被清空,从头开始写。