name=setname; if(setname=="0") break; if(setname!="0") { N++; num++;
outfile<<num<<" "; outfile<<setname<<" "; cout<<"请输入性别:"<<endl; cin>>setsex; sex=setsex; outfile<<setsex<<" ";
cout<<"请输入政治面貌:"<<endl; cin>>setpolitic; politic=setpolitic;
outfile<<setpolitic<<" ";
cout<<"请输入家庭住址:"<<endl; cin>>setaddress; address=setaddress;
outfile<<setaddress<<endl; } }
outfile.close(); //----关闭文件---- }
void student::add() {
string addname,addsex,addpolitic,addaddress;
//----以追加的方式录入信息,直接将信息追加到以前文件的末尾---- ofstream outfile("f1.txt",ios::app); if(!outfile) { cerr<<" open error"<<endl; exit(1); }
N=N+1;
//----依次输入相应的数据,并且追加到之前的文件中去---- cout<<"请输入您要添加的数据"<<endl; num++;
outfile<<num<<" "; cout<<"请输入姓名:"<<endl;