fstream contactfile; contact* temp; contact* remove; contact* newcontact; char tempname[50]; char tempphone[50]; char tempemail[50]; case 4: contactfile.open("contacts.dat",ios::out); temp=first; while(temp!=NULL){ contactfile << temp->getname() << endl; contactfile << temp->getphone() << endl; contactfile << temp->getemail() << endl; temp=temp->getnext(); } contactfile.close(); case 5: temp=first; while(temp!=NULL){ remove=temp; temp=temp->getnext(); delete remove; } first=NULL; contactfile.open("contacts.dat",ios::in); while(contactfile.eof()==0 ) { newcontact=new contact; contactfile.get(tempname,50,'\n'); contactfile.get(nl); contactfile.get(tempphone,50,'\n'); contactfile.get(nl); contactfile.get(tempemail,50,'\n'); contactfile.get(nl); newcontact->setname(tempname); newcontact->setemail(tempemail); newcontact->setphone(tempphone); if(first==NULL) first=newcontact else temp->setnext(newcontact); temp=newcontact; } temp->setnext(NULL); contactfile.close();