Reading values from a text file
I'm creating a gambling game where the user's info (first/last name, running total of winnings) is stored in a text file.
If the user already has a file, it reads the file. The file looks like this:
Name: Steve Jobs
Balance: 300
Rounds won: 5
I was wondering how I could extract the value of Balance (in this example, 300) and use it as a variable so i could add/subtract to it everytime the player wins/loses.
Thanks!
Re: Reading values from a text file
Option A
Read entire line and split the 300 value out.
Option B
Read the text "Balance:"
then read the int 300
Re: Reading values from a text file
Thanks! But how would that translate into code? Option B looks like the most straightforward