请问c++链表程序为什么写入之后,后添加的name会覆盖前面的name?
#include <iostream>#include <string>#include <cstring>#include <fstream>using namespace std;struct table{ table():next(NULL),prev(NULL){}; table(int id_t,char* name_t,int age_t): id(id_t),name(name_t),age(age_t),next(NULL),prev(NULL){} int id; char* name; int age; table* next; table* prev;};void ofRead(const char* file,table* head)//写入文件函数实现{ ofstream of(file,ios::app); of.seekp(0,ios::beg); table* cur=head; do{ of<<cur->id<<' '<<cur->name<<' '<<cur->age<<' '; cur=cur->next; }while(cur!=NULL); of.close();}void Create()//创建链表并写入文件{ table* head=NULL,*tail=NULL,*memory=NULL; string str("Yes"); char choice[4]=""; do{ cout.flush(); int id,age; char name[10]=""; cout<<"input new student with student's name,id and age into the table.txt"<<endl; cin>>name>>id>>age; memory= new table(id,name,age); if(head==NULL&&tail==NULL) { head=memory; tail=memory; } else { tail->next=memory; memory->prev=tail; tail=memory; } printf("choose Yes to go ahead,choose No to quit:"); cout.flush(); cin>>choice; }while(str==choice); ofRead("c:/table.txt",head);}int main(){ Create();}