为什么使用了ios::app txt中的数据还是被覆盖了

引用以下代码的时候会覆盖掉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();//关闭文件流

}

你用的不是ios::ate吗??? 换成ios::app就行了

你确定用ios::app试过吗,我运行了你的代码用ios::app是可以的,你检查一下是否别的地方对这文件操作了