HELP!! me annalyze this piece of code in file handling... O.O

can anyone tell me which part/line of this code makes the recorded data to be deleted.. i'm actually trying to make an employers payroll record that adds, display, delete and update a certain record..
i tried to remove the data.write but still it deletes the file, i dun have idea now what really deletes the file.... HELP PLEASE!!
here is the function definition of the code...


[purple]void delEmp(){
fstream data, temp;
emp e;
int eno;

cls();
cout<<"===== Delete Record ====="<<endl;
cout<<endl<<endl<<endl;
cout<<"Enter ENO to delete record ";cin>>eno;

rename("data.dat","temp.dat");

data.open("data.dat",ios::app);
temp.open("temp.dat",ios::in);

temp.seekg(0,ios::beg);

while(temp.read((char*)&e,sizeof(e))){
if(!(e.eno==eno)){
{ cout<<"Ecxisting records "<<e.eno<<endl;}
data.write((char*) &e,sizeof(e));
}
}
data.close();
temp.close();

system("Del temp.dat");

main();
}[/purple]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories