Thanks for the help in advance.
void Cancel()
{
int idnumber;
int contact;
char name[100];
char country[100];
char street[100];
char parish[100];
char category[100];
char booking[100];
char idtype[100];
char reservation[100];
string reservation1;
int reserveid=0;
int found=0;
int in;
char ch;
cout<<"Do you want to cancel a guest reservation:";
do
{
cin>>ch;
if(ch=='n'||ch=='N')
break;
cout<<"Please enter the guest ID you wish to cancel:";
cin>>reserveid;
fstream file;
file.open( "guest.txt", ios::in | ios::out);
if ( !file )
{
cerr << "File could not be opened" << endl;
exit( 1 );
}
guest info1;
while(!file.eof())
{
file >> idnumber >> contact >> name >> street >> parish >> country >> category >> booking >> idtype >> reservation;
info1.setinfo(idnumber,contact,name,street,parish,country,category,booking,idtype,reservation);
if(reserveid==info1.getidnumber())
{
info1.display();
string set="No";
info1.setreservation(set);
reservation1=info1.getreservation();
fstream file2;
file2.open("temp.txt",ios::out);
if ( !file2 )
{
cerr << "File could not be opened" << endl;
exit( 1 );
}
file2 << idnumber << ' ' << contact << ' ' << name << ' ' << street << ' ' << parish << ' ' << country << ' ' << category << ' ' << booking << ' ' << idtype << ' ' << reservation1 << endl;
file2.close();
}
fstream file3;
file3.open("temp.txt",ios::out|ios::app);
while((file >> idnumber >> contact >> name >> street >> parish >> country >> category >> booking >> idtype >> reservation))
{
info1.setinfo(idnumber,contact,name,street,parish,country,category,booking,idtype,reservation);
file3 << idnumber << ' ' << contact << ' ' << name << ' ' << street << ' ' << parish << ' ' << country << ' ' << category << ' ' << booking << ' ' << idtype << ' ' << reservation << endl;
}
remove("guest.txt");
rename("temp.txt","guest.txt");
file3.close();
break;
}
file.close();
cout<<"\nDo you want to cancel another reservation:";
cin >> ch;
}while(ch=='y' || ch=='Y');
cout<<"\n";
system("pause");
}


Sign In
Create Account


Back to top









