Compiler not searching well in the file

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<fstream.h>
class x
{
int rollno;
char name[10];
public:
void mod()
{
cout<<"\nEnter rollno ";cin>>rollno;
cout<<"Enter name ";gets(name);
}
void show()
{
cout<<"\nRollno : "<<rollno;
cout<<"\nName : "<<name;
}
int call()
{
return rollno;
}
};
void main()
{
clrscr(); x c;
fstream file("list.doc",ios::in|ios::out);
cout<<"The file contains this \n";
while(!file.eof())
{
file.read((char*)&c,sizeof(c));
c.show();
}
file.seekg(0);
cout<<"\nWanto to modify anything (y/n) ";char op;
cin>>op;
if(op=='y')
{
cout<<"Enter rollno to be modified ";int n;cin>>n;
while(!file.eof())
{
int pos=file.tellg();
file.read((char*)&c,sizeof(c));
if(c.call()==n)
{
file.seekg(pos);
c.mod();
file.write((char*)&c,sizeof(c));
}
}
}
file.seekg(0);
cout<<"The file now contains ";
while(!file.eof())
{
file.read((char*)&c,sizeof(c));
c.show();
}
file.close();
}


The file contains a record with roll no "11".But when the compiler asks me to enter roll no to be modified and I enter "11", it closes down and doesn't show anything.Please help!!
Topic archived. No new replies allowed.