Im trying to make a Banking Management System in C++. I am using file handling to parse data into program. Following is the snippet of code. I get into memory access denied issue whenever the data is parsed.
void Controller::displayCustomers()
{
vector<Customer> custVector;
Customer cust;
fstream fin("customer.dat", ios::binary | ios::in);
while (!fin.eof())
{
while (fin.read(reinterpret_cast<char*>(&cust), sizeof(cust)));
{
custVector.push_back(cust);
}
}
fin.close();
cout << "ID\tNAME\tADDRESS\tPHONE\t\tDOB\tPASSWORD\tBALANCE" << endl;
for (vector<Customer>::iterator itr = custVector.begin();
itr != custVector.end(); ++itr)
{
cout << itr->getID() << "\t" << itr->getName() << "\t" << itr->getAddress() << "\t"
<< itr->getPhone() << "\t" << itr->getDob() << "\t" << itr->getPass() <<
"\t" << itr->getBalance() << endl;
}
cout << endl;
}
What should be the solution?