一个小函数,就是从文件里面读取的数据不是原来的数据,请各位大侠们看看,很短的。
void student::readdate()//从文件读取数据{
class student *p1, *p2;
ifstream infile("f1.txt",ios::in);
if (!infile)
{
cout<<"文件打开错误!";
return ;
}
infile>>totall_num;
head=p1=p2=new class student;
infile>>p1->num;
infile>>p1->name;
infile>>p1->birthday;
infile>>p1->age;
infile>>p1->dizhi;
infile>>p1->dianhua;
infile>>p1->youbian;
infile>>p1->E_mail;
while(infile!=0)
{
p1=new class student;
infile>>p1->num;
infile>>p1->name;
infile>>p1->birthday;
infile>>p1->age;
infile>>p1->dizhi;
infile>>p1->dianhua;
infile>>p1->youbian;
infile>>p1->E_mail;
p2->next=p1;
p2 = p1;
}
p2->next=NULL;
infile.close();
totall_num=i;
}