-
Apr 10, 2009, 04:52 PM
#1
How Read From a Sequence File Sequentialy C++ and display results to user.
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();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules