How to do save files for a game.

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.)

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. =]