void modify_account(int n) { int found=0; fstream File; File.open("account.dat",ios::binary|ios::in|ios::out); if(!File) { cout<<"File could not be open !! Press any Key..."; return; } while(!File.eof() && found==0) { File.read((char*)&ac, sizeof(ac)); if(ac.retacno()==n) { ac.show_account(); cout<<"\n\nEnter The New Details of account"<<endl; ac.modify(); int pos=(-1)*static_cast<int>(sizeof(account)); File.seekp(pos,ios::cur); File.write((char*) &ac, sizeof(ac)); cout<<"\n\n\t Record Updated"; found=1; } } File.close(); if(found==0) cout<<"\n\n Record Not Found "; }
void main() { char ch1,ch2; while(1) { clrscr(); gotoxy(30,5); cout<<"ABHISHEK TELECOM PVT. LTD."; gotoxy(30,6); cout<<"__________________________"; gotoxy(30,8); cout<<"`M'anage Customer Records"; gotoxy(30,10); cout<<"`D'isplay Customer List"; gotoxy(30,12); cout<<"`G'enerate Bill"; gotoxy(30,14); cout<<"`E'xit"; gotoxy(30,24); cout<<"Enter your choice:"; ch1=getch(); ch1=toupper(ch1); switch(ch1) { case('D'): obj.display(); break; case('G'): obj.generate(); break; case('E'): clrscr(); exit(1); break; case('M'): ch2='A'; do { clrscr(); gotoxy(30,5); cout<<"ABHISHEK TELECOM PVT. LTD."; gotoxy(30,6); cout<<"__________________________"; gotoxy(30,8); cout<<"`A'dd Customer Records"; gotoxy(30,10); cout<<"`M'odify existing Records"; gotoxy(30,12); cout<<"`D'elete existing record"; gotoxy(30,14); cout<<"`E'xit"; gotoxy(30,24); cout<<"Enter your choice:"; ch2=getch(); ch2=toupper(ch2); switch(ch2) { case('A'): obj.add(); break; case('M'): obj.modify(); break; case('D'): obj.del(); break; case('E'): break; }//End of inner switch-case block }while(ch2!='E');//End of do-while block }//End of outer switch-case block }//End of while block }//End of main()