qq_36584323 2016-12-23 02:58 采纳率: 100%
浏览 1483
已采纳

c++输出到文件中保存不全

为什么每次只保存最后一次输出到文件中的呢,其他的不保存呢,是因为每次打开时,都将原来的清空了吗?

  • 写回答

6条回答 默认 最新

  • shen_wei 2016-12-23 06:53
    关注
     "r" 
    Opens for reading. If the file does not exist or cannot be found, the fopen call fails. 
    "w" 
    Opens an empty file for writing. If the file exists, its contents are destroyed. 
    "a" 
    Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesn't exist. 
    "r+" 
    Opens for both reading and writing. (The file must exist.) 
    "w+" 
    Opens an empty file for both reading and writing. If the file exists, its contents are destroyed. 
    "a+" 
    Opens for reading and appending; the appending operation includes the removal of the EOF marker before data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesn't exist. 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥50 用AT89C52单片机设计一个温度测量与控制电路
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义
  • ¥15 嵌入式--定时器使用
  • ¥20 51单片机学习中的问题
  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库