I'm not sure what's happening here. But this is just a simple loop that reads data into a struct (account) from a file until the eof is reached and then displays it. The problem is, for some reason, the last entry is displayed twice. How could this be?
Code:void displayAccounts(account *a) { fio.seekg(ios_base::beg); while(!fio.eof()) { fio.read((char *) a, (sizeof account)); cout << "Account type: "<< a->type << "\n"; cout << "Name: "<< a->name << "\n"; cout << "Address: " << a->address << "\n"; cout << "Balance: " << a->balance << "\n"; cout << "PIN: " << a->pin << "\n\n"; } }
Thanks in advance, Invincible