Saving an unspecified sub-string to a new string?
I have an assignment involving accounting. I need to use data from a file, with a format like this:
Name, action(set balance, withdraw, deposit), amount, all in one line, and the same string.
I need to set up individual accounts for each name entered (as they are entered, so there can be as many accounts as necessary).
But I no idea how to differentiate between the account names, as well as finding the number in it. I'm not all that great with strings and
methods relating to them. For example, the input would look like this:
NAME BALANCE 123
NAME2 BALANCE 4324
NAME WITHDRAW 70
NAME 2 DEPOSIT 42
And so on, like that, but as input all at once from a file. I'm completely lost with this, and I have no idea how I should go about it. Does
anyone have any ideas or suggestions? If you do, thanks a lot.
Re: Saving an unspecified sub-string to a new string?
Check out the split method. It will return an array with 3 elements (name, action, amount).