would anyone help me to settle this function?
for your information, i want to delete certain information from the database.
example in the the database is name, address, and room number
i just want to edit the room number of certain person from the database, anyone who know how to do that please tell me later.
thanx in advance.
Code:
void buyticket(int m){
fstream ticket("cruise.dat", ios::in | ios::out); //open patient's file
if(!ticket)
{
cout<<"File could not be opened to read."<<endl;
exit(1);
}
ticket.seekg(0);
ship data;
ticket.seekg( (m-1) * sizeof(ship) );
ticket.read((char *)&data, sizeof(ship));
cout<<"Available ticket : "<< data.return_room() <<endl;
int avalroom,befroom;
cout<<"Enter room : "<<endl;
cin>>avalroom;
befroom=data.return_room();
room=befroom-avalroom;
cout<<"After : "<<room<<endl<<endl;
ticket.seekp( (m-1) * sizeof(ship) );
ticket.write((char *)&data,sizeof(ship));//write into the binary file
cout<<"Record Modified!"<<endl;
ticket.close();
getch();
}