@@@@@@@@@@@@@@@@@@@@如何读取二进制文件所保存的链表信息@@@@@@@@@@@@@@@@@
typedef struct L
{
char name[20];
int id;
int chinese;
int english;
int math;
struct L * next;
}Lcx, * Lmycx;
struct L * Find::creat()
{
struct L * head,*p,*s;
int i,j;
cout<<"请输入人数: "<<endl;
cin>>j;
head=(struct L *)malloc(sizeof(Lcx));
p=head;
for(i=0;i<j;i++)
{
cout<<"请输入姓名:"<<endl;
s=(Lcx *)malloc(sizeof(Lcx));
cin>>s->name;
cout<<"请输入id:"<<endl;
cin>>s->id;
cout<<"请输入语文成绩:"<<endl;
cin>>s->chinese;
cout<<"请输入英语成绩: "<<endl;
cin>>s->english;
cout<<"请输入数学成绩: "<<endl;
cin>>s->math;
p->next=s;
p=s;
}
head=head->next;
p->next=NULL;
return (head);
}
我的链表保存方法:
void Find::Save(struct L * head) //head为链表头指针
{
struct L *p;
p=head;
ofstream outbal("chenxiao.asc",ios::out|ios::binary);
if(!outbal)
{
cout<<"Cannot open output file."<<endl;
exit(1);
}
while( p!=NULL)
{
outbal.write((const char *) p,sizeof(struct L));
p=p->next;
}
outbal.close();
}
请问如何读取二进制文件所保存的链表信息。
问题点数:0、回复次数:0Top




