This is the function that reads the file and I have tested it and it worked.
int readAccts(string acct[maxAccounts], int pin[maxAccounts], double bal[maxAccounts], int & numAccts)
{
ifstream fin;
fin.open("accounts.txt");
if (fin.fail())
{
cout << "Error in reading accounts!" << endl;
return -1;
}
//string acct, pin, bal;
fin >> numAccts;
cout << "num=" << numAccts << endl;
for (int i = 0; i < numAccts; i++)
{
fin >> acct[i] >> pin[i] >> bal[i];
printAccts();
}
}
This code is suppose to print the read file and is invoked in the read function
int printAccts()
{
for (int i = 0; i < numAccts; i++)
{
cout << acct[i] << pin[i] << bal[i] << endl;
}
}
This is the code that invokes the read function (printLogo works)
void startUp()
{
printLogo();
cout << "Starting up INSTA-ATM..." << endl;
readAccts();
}
text file
4
MB-1111-1111 1111 222.22
MB-2222-2222 2222 333.33
B1-3333-3333 3333 444.44
4444 4444 555.55
I am not sure what to put in for the arguments when I invoke the functions any help would be greatly appreciated.