I'm doing a project for school, and am at an impasse. The program is working correctly until it comes to reading data from a file via a loop into an array. It returns nothing back. Below are the results of my program:
Billable Items
Team Member Name Team Member Amount Billed
0
0
0
Grand Total: 4100
And this is the code I'm using to read into the array:
void displayGrandTotal()
{
string clientNameHolder = " "; // We declare variables to hold our read values.
int invoiceNumberHolder = 0;
double grandTotalHolder = 0.00;
string teamMemberHolder[ARRAYSIZE] = {" "};
double memberTotalHolder[ARRAYSIZE] = {0.00};
readFile.open("DataFile.txt"); // Now we open the file we read from.
getline(readFile, clientNameHolder);
readFile >> invoiceNumberHolder;
readFile >> grandTotalHolder;
// Here, we create a loop that reads all of the values in the file.
for (int counter = 0; counter < NumOfTM ; counter++)
{
getline(readFile, teamMemberHolder[counter]);
readFile >> memberTotalHolder[counter];
}
readFile.close();
// Here, we will display an Invoice number and client information.
cout << "\n\n---------------\n\n";
cout << "Invoice #: " << invoiceNumberHolder << endl;
cout << "Client: " << clientNameHolder << endl;
cout << "---------------\n\n"; /* This will give separation to the name and
billing items for increased readability. */
cout << "Billable Items\n\n";
// Here, we will start the list of billable hours.
cout << endl << "Team Member Name\t" << "Team Member Amount Billed\n";
for (int index3 = 0; index3 < NumOfTM; index3++) /* This will display the billing
information on the bill. */
{
cout << teamMemberHolder[index3] << "\t\t\t" << memberTotalHolder[index3];
cout << endl;
}