这个是读取文件
student *ps=head;
ifstream infile("txl.dat",ios::in|ios::binary);
while(ps)
{
infile.read((char*)&ps->stud,sizeof(ps->stud));
ps=ps->next;
} //从文件中读取所有信息
infile.close();
这个是向文件输入
student *ps=head;
ofstream outfile;
outfile.open("txl.dat",ios::binary|ios::trunc);
while(ps)
{
outfile.write((char *)&ps->stud,sizeof(ps->stud));
ps=ps->next;
}
outfile.close(); |