链表求帮助
void CreatCustomer(customer *customer1){
system("cls");
customer *p;
p=customer1;
while (p->next!=NULL){
p=p->next;
}
p=new customer;
cout << "Please enter the id:\n";
cin >> p->id;
cout << "\nPlease enter the passwords:\n";
cin >> p->password;
p->next=NULL;
cout << "\nCreat new user sucesssfully!\n";
system("pause");
}
customer* customer::Read(){
customer *head,*p1,*p2;
head=p1=new customer;
p2=new customer;
fstream f("customer.txt",ios::in|ios::binary);
if(f.fail()){
cout<<"\nFailed to open the file!\n";
system("pause");
exit(0);
}
f.read((char*)p2,sizeof(customer));
while(!f.eof()){
p1->next=p2;
p1=p2;
p2=new customer;
f.read((char*)p2,sizeof(customer));
}
p1->next=NULL;
free(p2);
f.close();
return head;
}