void Staff::Delete() { char tgtIC[15]; Staff objStaff; fstream iofile( "Employee.dat",ios::in || ios::out); if (!iofile) // overloaded ! operator { // or: if( outClientFile.fail() ) cerr << "\t File could not be opened" << endl; system( "PAUSE" ); exit( 1 ); // prototype in cstdlib } fflush(stdin); // To remove any previous content stored in memory cout<<endl; cout<< "\t ==================================================" cout<< "\t < DELETE A RECORD >" <<endl; cout<< "\t Enter IC that you want to delete : " cout<< "\t ==================================================" <<endl; cout<< "\t | Enter Staff IC : " ; cin.getline(tgtIC, 15); //==================================================" <<endl; iofile.read((char *) (&objStaff), sizeof(Staff)); while (!iofile.eof()) { //cout<< "t :" <<tgtIC<< "obj : " <<objStaff.IC<<endl; if (!strcmp(tgtIC,objStaff.IC)==0) display(objStaff); else cout<< "\t Delete record - by writing a blank record if using random file" <<endl; iofile.read((char *) (&objStaff), sizeof(Staff)); } iofile.close(); // explicit closing }
iofile.read((char *) (&objStaff), sizeof(Staff));
objStaff
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)