I already know how to use fstream. I know to save the value variables to a file, and I also know how to make the program display the information in the file, but my problem is that it saves the content of the variable, not the variable itself.
Here's what I mean:
Let's say there's a variable called chargold, and it had a value of 10. It would save the number 10. I want to know how to make the program recognize that the 10 belongs to chargold, so that the amount of gold the character has will be saved.

How would I go about doing this? (If what I'm asking is still unclear, let me know. I can try to clarify it further.)

1) By always outputting and inputting the exact same format in each file. chargold is always, say, the third value read.

2) By outputting the name as you output the value: fdat << "chargold=" << chargold << endl; Then as you read the file, when you read "chargold=", the data following can be moved into the variable.

Personally, I prefer #1. It's easier.

I was doing #1 already, but I figured out what I was doing wrong. It was a very, very stupid mistake actually. I got my ifstream and ofstreams confused. I felt very dumb after I realized it. Thank you for your help. =]

This question has already been answered. Start a new discussion instead.