chaoseverlasting
- 1,050
- 3
Hi, I am trying to display all the records stored in a file(Banac.dat) but the program keeps on returning the first record over and over again in an endless loop ( i think its endless). If anyone could help me, it would be appreciated.
For the sake of simplicity, I've only included the errenous function and the class definition, if anyone wants to see the whole program, just ask.
For the sake of simplicity, I've only included the errenous function and the class definition, if anyone wants to see the whole program, just ask.
Code:
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>char ch;
int ac=0;
int flag=0;
int acn;
float bal;
class account{
private:
char name[20], address[20], dob[10], type[2];
float balance;
int acno;
public:
account(float b=0):balance(b){};
void create();
void close();
void withdrawal();
void deposit();
void report();
void search();
void disp();
};fstream file;void account::report()
{
clrscr();
file.open("Banac.dat", ios::binary|ios::in);
while(!file)
{
file.read((char *)this, sizeof(account));
disp();
cout<<endl<<endl;
}
getch();
file.close();
} //End of void report();
Last edited by a moderator: