vendredi 25 janvier 2019

Why isnt this delete function not letting me add a record in my directory system [on hold]

  void delrec()
{
char delname[30];   //for checking the record to be deleted
fstream F1,F2;
F1.open("phonedirectory.dat",ios::binary|ios::in);
F2.open("temp.dat",ios::binary|ios::app);
Directory D;
int del=0;//checking if name found
cout<<"Enter the name of the record you want to Delete - ";
gets(delname);
  {
  while(F1.read((char*)&D,sizeof(D)))
  if((strcmpi(delname,D.rname()))!=0)
    {
     F2.write((char*)&D,sizeof(D));
    }
    else
    del++;
  }
 if(del)
 cout<<"The record has been deleted";
 F1.close();
 F2.close();
 remove("phonedirectory.dat");
 rename("temp.dat","phonedirectory.dat");
 sortname();
 getch();
}

When I use this function. I go to type something and it dosen't show anything. When I press the second time it just brings me back to the menu of this program

What its meant to do is I enter something , it checks if that thing is available to delete or not and then delete it. Then go back to the menu

Aucun commentaire:

Enregistrer un commentaire