Hopefully someone can tell me what I'm doing wrong. I'm reading up to a specific point on each line within a text file and then trying to add that value to the value on the next line and continue doing so until the end of the file/loop. But at the moment, it will only add the values from the first two lines and not...
123 + 456 + 789 = totalPayroll.
My code is as follows:
inStream.open("staffMembers.txt");
while(getline(inStream.ignore(256, '$'), line))
{
totalPayroll = stoi(line) + stoi(line);
}
inStream.close();
cout << "$" << totalPayroll << endl;
My text file is formatted as follows:
1 | Person One | $123
2 | Person Two | $456
3 | Person Three | $789
totalPayroll += stoi(line);?a+=bis equivalent ofa = a+ b