读入txt问题

每次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);

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

原文地址:https://www.cnblogs.com/xiangshancuizhu/p/2409187.html