I've just started scripting and have written a small prog that playes blackjack with the user. What I was wondering, how would I make it so the game saved the amount of money the user won and then loaded this amount the next time the game is played?
I've just started scripting and have written a small prog that playes blackjack with the user. What I was wondering, how would I make it so the game saved the amount of money the user won and then loaded this amount the next time the game is played?
Um.. I know how to save in C and C++, but I don't know how to do it in Unix scripting which is what the program is written with.
Here's one way
Code:SCORE=10 echo "SCORE is $SCORE" echo $SCORE>score.txt SCORE=0 echo "SCORE is $SCORE" if [ -f score.txt ] then SCORE=$(cat score.txt) fi echo "SCORE is $SCORE"
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]