The data that needs to be saved depends entirely of you and how much you want to reconstruct of the game when the user loads the savedata. For example, if you make a 2d side scrolling game like sonic, then you only need to save the rings number, level, score, emeralds, lives and optionally the checkpoint number in the level (of course, if you want to save only the level and drop everything else its fine too).
If you game is simple enough then yu can save simple data types, else you could save the structs, or if you are using objects then you can serialize them to the savedata so you can load the exact state later.
If you are asking how then it can be as simple as:
- Code: Select all
typedef struct {
int level;
int score;
} savedata;
........
savedata data;
.........
data.level = current_level;
data.score = current_score;
fwrite(&data, sizeof(data), 1, fd); //if you are managing the file yourself
// or just call the savedata_utility and give them the struct pointer
..........
Also you don't need to worry about that "gibirish code/data", just read it in the same way that you are saving it and you will be fine.