每次close之后,想继续读入而不擦除原来的内容,可以这样写:

ofstream area_file ("area.txt",ios::app|ios::out|ios::in);

 而每次均要擦除,这样写:

ofstream area_file ("area.txt",ios::trunc|ios::out|ios::in);
ofstream area_file ("area.txt",ios::ate|ios::out|ios::in);

 经过测试,效果是这样的!

 

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-12-26
  • 2021-08-11
  • 2021-07-06
  • 2022-12-23
  • 2021-10-01
猜你喜欢
  • 2022-01-24
  • 2023-01-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案