Where "Smith, John" is the last and first name, "20" is age and "$1239" is the amount in their checking account. How do you read this line and sum up the total amount in all these customers' bank accounts? I got as far as this:
int main () {
int num;
string str;
ifstream accounts ("checking_accounts.txt");
getline (accounts, name, ":");
getline (accounts, age, "$");
}
And couldn't figure out how to get the dollar amount without reading the next person's name.
I'm trying to do this without using arrays/vectors, as my course has not covered these topics yet. Thanks for any feedback!
maybe you could use cin.get() with loops and a peek() function. I've never used peek(), so I don't know exactly how it works, but the reference section on this sight could explain how.
Hm. I would suggest just using operator >> here since you know the next part is a number and that operator will stop when it reads a non-number character.