引用以下代码的时候会覆盖掉txt文本内原有的数据,为什么,改怎么解决
void save(Student stu[]) {
ofstream outfile("student.txt",ios::ate);
if (!outfile) { //若不存在outfile则异常终止
cout << "打开异常" << endl;
exit(1);
}
for (int i = 0; i < total; i++) {
outfile << stu[i].name << "\t" << stu[i].stunumber << "\t" << stu[i].math << "\t"
<< stu[i].physical << "\t" << stu[i].english << "\t" << stu[i].average << '\n';
//将数据写入txt文件
}
outfile.close();//关闭文件流
}