HI..
I'm working on an initial level project
using c++ and file handling
i need a help
can anyone guide me
i want to delete the record of an employee wat will b the syntax for this
coz i'm having some problem in this piece of code
int employee::retemp_ID()
{
return emp_ID;
}
void delete_emp(int n)
{
employee e;
ifstream inFile;
ofstream outFile;
inFile.open("account.txt",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
outFile.open("Temp.dat",ios::binary);
inFile.seekg(0,ios::beg);
while(inFile.read((char *) &e, sizeof(employee)))
{
if(e.retemp_ID()!=n)
{
outFile.write((char *) &e, sizeof(employee));
}
}
inFile.close();
outFile.close();
remove("account.txt");
rename("Temp.dat","account.txt");
cout<<"\n\n\tRecord Deleted ..";