Hey everyone, I need a little help understanding some of the logic or code behind a project I have to do. I need to read a checkbook register file one line at a time, and calculate the balance by adding deposits and subtracting checks.
I've prompted the user to enter the file, but I need to ignore whitespace so if they put a space, it doesn't cause a mess. I thought that skipws would do that, but I might not be using it right.
Another catch is that I must remove/ignore the colons from the input lines separating each line into four separate pieces of data: the word "deposit," a date, the recipient of the check (or a dash), and the amount of the check or deposit.
Here's what the input would like like as a test case:
Lines that begin with "deposit" represent deposits; the fourth field represents the deposit amount and is added to the balance. The third field of a deposit only contains a dash. ones that begin with a number represent checks; the fourth field represents the check amount and is subtracted form the balance.
The hard part im understanding is the skipws for the whitespace, and the adding/subtracting lines. Here's my code thus far:
using namespace std;
cout << "Enter a file name (including extension): " << endl;
cin >> skipws >> FileName;
cerr << "Unable to open file" << endl;
input.getline(deposit, 15, ':');
cout << left << setw(15) << deposit;
input.getline(date, 15, ':');
cout << setw(15) << date;
input.getline(place, 15, ':');
cout << setw(15) << place;
cout << right << setw(15) << "$ " << money << right << endl;
for(int j=0; j<65; j++)
cout << '-';
cout << endl;
It runs fine, there aren't any errors, just need help understanding what is being asked.