void func7()
void func04()
{
ifstream input("MyFrd2.dat");
studentteacher s;
cout<<"输出数据"<<endl;
cout<<setiosflags(ios::left)
<<setw(10)<<"姓名"<<setw(18)<<"身份证号码"<<setw(20)<<"班级"<<setw(20)<<"成绩"<<setw(20)<<"职称"<<setw(20)<<"学院"<<endl;
input.read((char *)&s,sizeof(s));
while(input)
{
s.disp();
input.read((char*)&s,sizeof(s));
};
input.close();
}
void func05()
{
char sname[10];
ifstream file("MyFrd2.dat");
studentteacher one;
file.seekg(0);
cout<<"输入要查询的姓名(可只输入姓氏):";
cin>>sname;
cout<<"输出查询结果:"<<endl;
cout<<setiosflags(ios::left)
<<setw(10)<<"姓名"<<setw(18)<<"身份证号码"<<setw(20)<<"班级"<<setw(6)<<"成绩"<<endl;
file.read((char*)&one,sizeof(one));
while(file)
{
if(comp(one.getname(),sname)==1)
one.disp();
file.read((char*)&one,sizeof(one));
};
file.close();
}
void func06()
{
fstream outapp("MyFrd2.dat",ios::app);
studentteacher one;
cout<<"添加数据:";
one.getdata();
outapp.write((char*)&one,sizeof(one));
outapp.close();
}
void func07()
{
char sname[12];
int i=0;
fstream outdel("MyFrd2.dat",ios::in|ios::out);
studentteacher one;
outdel.seekg(0);
cout<<"输入要删除的姓名(可只输入姓氏):";
cin>>sname;
while(!outdel.eof())
{
outdel.seekp(sizeof(studentteacher)*i);
outdel.read((char *)&one,sizeof(one));
if(comp(one.getname(),sname)==1&&one.gettag()=='#')
{
outdel.seekp(sizeof(studentteacher) *i);
outdel.put('*');
}
i++;
}
outdel.close();
}
void func08()
{
fstream outdel("studentteacher.dat",ios::in);
fstream temp("temp",ios::out|ios::trunc);
studentteacher s;
while(!outdel.eof())
{
outdel.read((char *)&s,sizeof(studentteacher));
if(s.gettag()=='#')
temp.write((char *)&s,sizeof(studentteacher));
}
outdel.close();
temp.close();
fstream outdel1("MyFrd2.dat",ios::out|ios::trunc);
fstream temp1("temp",ios::in);
while(!temp1.eof())
{
temp1.read((char *)&s,sizeof(studentteacher));
outdel1.write((char *)&s,sizeof(studentteacher));
}
outdel1.close();
temp1.close();
cout<<"此记录已物理删除"<<endl;
}
void func09()
{
char sname[10];
ifstream file("MyFrd.dat");
student one;
file.seekg(0);
cout<<"输入要修改的姓名(可只输入姓氏):";
cin>>sname;
cout<<"输出查询结果:"<<endl;
cout<<setiosflags(ios::left)
<<setw(10)<<"姓名"<<setw(18)<<"身份证号码"<<setw(20)<<"班级"<<setw(6)<<"成绩"<<endl;
file.read((char*)&one,sizeof(one));
while(file)
{
if(comp(one.getname(),sname)==1)
one.disp();
file.read((char*)&one,sizeof(one));
};
file.close();
ofstream output("MyFrd.dat");
student s;
cout<<"重新输入数据:"<<endl;
s.getdata();
output.write((char *)&s,sizeof(s));
output.close();
}
void func10()
{
char sname[10];
ifstream file("MyFrd1.dat");
teacher one;
file.seekg(0);
cout<<"输入要修改的姓名(可只输入姓氏):";
cin>>sname;
cout<<"输出查询结果:"<<endl;
cout<<setiosflags(ios::left)
<<setw(10)<<"姓名"<<setw(18)<<"身份证号码"<<setw(20)<<"班级"<<setw(6)<<"成绩"<<endl;
file.read((char*)&one,sizeof(one));
while(file)
{
if(comp(one.getname(),sname)==1)
one.disp();
file.read((char*)&one,sizeof(one));
};
file.close();
ofstream output("MyFrd1.dat");
teacher s;
cout<<"重新输入数据:"<<endl;
s.getdata();
output.write((char *)&s,sizeof(s));
output.close();
}