Well, I have one heck of a problem here. I'm making this simple game (code of the game not included) where one manages a colony in space. I've planned to include a save feature for the game, but I have no proper idea on how to make one. I got this far while testing:
#include <fstream>
#include <iostream>
usingnamespace std;
struct savedata{
int a;
int b;
int c;
};
int d;
int e;
int main()
{
savedata save;
savedata *ptr;
ptr = &save;
save.a = 1;
save.b = 2;
save.c = 3;
d = 4;
e = 5;
cout<<"\n";
ofstream a_file ("example.sav");
a_file << ptr->a << "\n" << ptr->b << "\n" << ptr->c << "\n" << d << "\n" << e << "\n";
a_file.close();
//Then comes the main problem.
//How do I load it and assign those values back to savedata's save's a, b, c, and
//the integers d and e?
}
As I'm a complete beginner, I really need some help, and some clear ones too. I would really appreciate if one you guys explained a way to do it step by step.
And if the comment was unclear, I want to load every number/text I wrote in it to be loaded into my game. Any help, please?