saving to binary files

How can messages (e.g. game saves) be saved to a binary file?

I spoke a while ago to a friend who recommended that .txt files weren't the best to use for saving games information. Apparently, the reason was based on their higher data consumption. Can anybody with any knowledge of this area recommend the best approach with binary files, in particular ".dat" files
Last edited on
Nothing wrong with storing gamesaves in txt files, however if you're storing binary data, there is a problem with not using the ios::binary flag.

You can always make up your own file extension.

How can they be saved:
Simply come up with a protocol.
for example: say I have a board game, chess, that I want to quit and come back to later;

I would define my protocol like this
[dead pieces: w_knight_1, b_queen, etc, etc] [living pieces b_knight_1{b,2},b_blah_#{x,y}]

get the picture?
Thanks, I can visualize it but the process of learning and knowing how they are implemented seems to be the challenge. Just as everything, it'll turn out to be simply straight forwards once you learn, but it just hard when you don't know where to begin.
Well it's entirely based on the particular game. There isn't really an end-all. Unless you want to save an image of your ram or something =)
Topic archived. No new replies allowed.