Detecting File Info (saving game info)

So I want to save my game in a single .txt file, that way I don't have to search through a ton of different files to load the game.
My idea is to save a character's name in one line then write in the ints for the character's stats on the next then the floats, doubles, etc. in following lines then repeat the whole process for the next character. But I also want to save game progress and board info after all characters have been saved.
What I need is a way to detect if a piece of information in a file is an int, float, string, etc. without crashing the program.

Should I load the info into a string first then check if I can convert the string to an int/float, or is there a way to check what type of info is on the next line without loading it into a variable first?
Check out comma-separated-values:

http://en.wikipedia.org/wiki/Comma-separated_values

basically, your text file looks something like this:

Player 1, 12, 24, 543
Player 2, 23, 23, 1024


Every player has the same format. So first extract the string getline(cin, str, ',');, get an int, ignore the comma, get another number...


Topic archived. No new replies allowed.