modify function is working fine for any record in file. only problem is that when i modify last record it works but showing extra garbage value ... please help...
void modify_account(int n)
{
bool found=false;
account ac;
fstream File;
File.open("account.dat",ios::binary|ios::in|ios::out);
if(!File)
{
cout<<"File could not be open !! Press any Key...";
return;
}
int pos=File.tellp();
while(File.read(reinterpret_cast<char *> (&ac), sizeof(account)) && found==false)
{
if(ac.retacno()==n)
{
ac.show_account();
cout<<"\n\nEnter The New Details of account"<<endl;
ac.modify();
File.seekp(pos,ios::beg);
File.write(reinterpret_cast<char *> (&ac), sizeof(account));
cout<<"\n\n\t Record Updated";
found=true;
}
}
File.close();
if(found==false)
cout<<"\n\n Record Not Found ";
}