C++ Function to edit a particular record in a binary file

Void editrec()
{
      fstream fio;
      student s;
int r;
fio.open("stud.dat",ios::binary|ios::out|ios::in);
fio.seekg(0);
cout<<" Enter the roll no. you want to edit : ";
cin>>r;
while(fio.read((char*)&s,sizeof(s)))
{
       if(r==s.retrno())
       {
cout<<"Record found !! ";
s.get();
fio.seekp(fio.tellp()-sizeof(s));
fio.write((char*)&s,sizeof(s));
}
}
fio.close();
}

Comments

Popular posts from this blog

List of Devices that will get Lineage OS 14.1 ROM

How to make pascal's triangle using for loop in c++