Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using tellg() and seekp() functions for performing the required task.
#include<fstream.h>
class Client
{
long Cno; char Name[20], Email[30];
public:
//Function to allow user to enter the Cno, Name, Email
void Enter();
//Function to allow user to enter (modify) Email
void modify();
long ReturnCno() (return Cno;)
};
void ChangeEmail()
{
Client C;
fstream F;
F.open("INFO.DAT", ios::binary|ios::out);
long Cnoc; // Client's no. whose Email needs to be changed
cin>>Cnoc;
while(F.read((char*)&C, sizeof(C)))
{
if(Cnoc == C.ReturnCno())
{
C.Modify();
// Statement 1
int Pos = _________ // To find the current position of file
// pointer
// Statement 2
_____________ //to move the file pointer to write the modified
// record back onto the file for the desired Cnoc
F.write((char*)&C, sizeof(C));
}
}
F.close();
}
Statement 1:
F.tellg();
Statement 2:
F.seekp(Pos-sizeof(C));
OR
F.seekp(-sizeof(C), ios::cur);