Page 389 - C++
P. 389
file.read((char *) this, sizeof(PASSANGER)) ;
if (file.eof())
break ;
if (sno != slno)
temp.write((char *) this, sizeof(PASSANGER)) ;
else
found = 1 ;
}
file.close() ;
temp. close () ;
file.open("PASS.DAT", ios :: out|ios::binary) ;
temp.open("temp.dat", ios :: in|ios::binary) ;
temp.seekg(0,ios :: beg|ios::binary) ;
while ( !temp.eof() )
{
temp. read ((char *) this, sizeof(PASSANGER)) ;
if ( temp.eof () )
break ;
file.write((char *) this, sizeof(PASSANGER)) ;
}
file.close() ;
temp. close () ;
return found ;
}
//---------------------------------------------------------------------------
// THIS FUNCTION CANCELS PASSANGER' S TICKET
//---------------------------------------------------------------------------
void RESERVE :: CANCELLATION (void)
{
clrscr() ;
char t1[10] , ch ;
int t2, tno, valid ;
do
{
valid = 1 ;
gotoxy(3,23) ; clreol() ;
cout <<"PRESS <ENTER> TO SEE LIST or 0 TO EXIT" ;
gotoxy(3,20) ; clreol() ;
cout<<"Enter Ticket no. of the Passanger to cancel the "
"Ticket " ;
gets(t1) ;
t2 = atoi(t1) ;
tno = t2;
if (t1[0] == '0' )
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
LIST() ;
clrscr() ;
}
if (!FOUND(tno) && valid)
{
valid = 0 ;
gotoxy(3,23) ; clreol() ;
cout<<" "<<"\n Record not found" ;
getch();
}
} while (!valid);
clrscr() ;
fstream file ;
file.open("PASS.DAT", ios ::in|ios::binary) ;
while (file.read((char *) this, sizeof(PASSANGER)))
if (ticketno == tno)