Hi,
I'm making a phone-book,i wanna edit a record of person.I tried to use seekp function to do so but failed,i'm using ios::app mode.
Guide me how to replace some data in the file.
If you want i'll send you complete program
void Update()
{
system("cls");
char Name[30];
int count=0,PointerPosition=0;
cout<<"Enter Your Full Name :";
cin.ignore();
gets_s(Name);
in.open("AddressBook.dat",ios::binary);
while(!in.eof())
{
in.read((char*)&Record,sizeof(Record));
if(strcmp(Name,Record.GetName())==0)
{
Record.update();/*this will update the Record*/
break;
}
count++;
}
in.close();
in.clear();
out.open("AddressBook.dat",ios::ate|ios::app|ios::binary);
PointerPosition=count*sizeof(Record);
out.seekp(PointerPosition);
out.write((char*)&Record,sizeof(Record));
out.close();
}