am doing a college project.

using c++ i write and read from a file user.dat

at times when i read from the file in a loop then i then try to display the results. the program crash.

however, if there are only one or two record in the file it displays the results.
when the file getlarge the program crash.


i also want to read a specify record in the file. and delete it and also update.

these are my codes

void user::display()
{
string name,address,gender;
int id,tel;
ifstream displayuser("user.dat",ios::in);
if(!displayuser)
{
cerr<<"Error opening file"<<endl;
exit(0);
}
while(!displayuser.eof())
{
displayuser>>name>>address>>id>>gender>>tel;
cout<<"NAME : "<<name<<endl;
cout<<"ADDRESS : "<<address<<endl;
cout<<"ID NUMBER : "<<id<<endl;
cout<<"GENDER : "<<gender<<endl;
cout<<"Contact NO: "<<tel<<endl;
}
displayuser.close();
}