I have a program that runs a bank management.It saves the created accounts in account.dat. For example these are the contents of the data file:
1001 felisilda s 5000
0002 smith s 3000
1212 johnson c 3200
I want the output to be sorted increasingly based on the bank account number, like this.
0002 smith s 3000
1001 felisilda s 5000
1212 johnson c 3200
here's the code for displaying:
void display_all()
{
account ac;
ifstream inFile;
inFile.open("account.dat",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n";
cout<<"====================================================\n";
cout<<"A/c no. NAME Type Balance\n";
cout<<"====================================================\n";
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
{
ac.report();
}
inFile.close();
}