the last record is getting displayed twice.i hv rechecked everything and cudnt find the error. here is the add n display function.
void add()
{
example abc;
int n;
ofstream file1("EXAMPLE.dat", ios::binary|ios::app);
cout<<"Enter Number Of Records To Add ";
cin>>n;
cout<<endl;
for ( int i = 0; i < n; ++i)
{
abc.getdetails();
file1.write((char*)&abc, sizeof(abc));
cout<<endl;
}
file1.close();
getch();
}
void display()
{
example abc;
ifstream file("EXAMPLE.dat", ios::binary);
while(file)
{
file.read((char*)&abc, sizeof(abc));
abc.showdetails();
cout<<endl;
}
file.close();
getch();
}
kindly help.
wid regards