how to delete a record from a txt file,I have been created the function but it doesn't work correctly
the function as following:
void DeleteRecord()
{
ReadRecord(); //for the function which I created to read a file
for(int i=0;i<counter;i++)
{
cout<< IDNum[i]<<"\t"<<FullName[i]<<"\t"<<LastName[i]<<"\t"<<phone[i]<<"\t"<<Nationality[i]<<endl;
}
int Id;
int num;
int c=0;
int index=-1;
cout<<"please enter the Id number to be deleted"<<endl;
cin>>Id;
int i;
for ( i=0; i<counter;i++)
{
if ( IDNum[i]==Id)
IDNum[i]==-1;
else
cout<<"ID not valid"<<endl;
Comments
Leave a comment