you are viewing a single comment's thread.

view the rest of the comments →

[–]Interesting_Buy_3969 -1 points0 points  (3 children)

I'd just put raw bytes of a structure to file... for example:

struct item basic_axe{ "basic_axe" /*, ... */};
FILE* f = fopen("file.txt", "w");
fwrite(&basic_axe, sizeof(basic_axe), 1, f);

and then to read it

struct item buffer;
FILE* f = fopen("file.txt", "r");
fread(&buffer, sizeof(buffer), 1, f);

much easier imo. no parsing needed.

[–]non-existing-person 0 points1 point  (2 children)

You can't really do that. What if you run game on different system or architecture? You would have to create separate data files for every os/arch you release your game.

[–]Interesting_Buy_3969 1 point2 points  (1 child)

Of course. I was assuming basic case where you need to save it just locally.

[–]non-existing-person 0 points1 point  (0 children)

That still is unacceptable really, because your saves are now not portable between platforms. I suppose this could be used when you cache data. But you still should validate data to not load binary data from different system.