0

I have no idea how to make somthing like this, and i'm kind of new with file I/O.
How would you start somthing like this?

O.k. here is what I have to save,
I have roughly 56+ variables that need to be counted in this.
But what I am having trouble with is when you write in a word doc it can't save the actual vairable values.
I need to save like if somthing is 1 or 0. Like if you equiped a weapon or not, or if a quest if active. And then acess that when you load the game back up, but I can't seem to get the variable to show up when you access the load screen so the game locks up when you access portions of the map that "are not acessed yet." Which should have been saved during the previous play.
(it's also annoying when you have to start over agian when you start up the game)
For example,
int x;
x = x + 1;
I need to save the value of x, being that it is a coordinate to the map, and load it from the file agian exactly as it saved it.

Anybody know how to do this, or at least give me a brief walkthrough with file I/O and or how to access and save to files?

Here is an example of two code snippets;

{
loadgame:
savefile1.open ("savefile1.txt", ios::out | ios::app);
savefile1.close();
goto maptest;
}
{
save:
savefile1.open ("savefile1.txt");
savefile1 <<"x ="<<x<<"\n"<<"y ="<<y<<"\n";
savefile1.close();
goto jumpto;
}

could someone tell me how to access those x and y variables?

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by MosaicFuneral
0

One way would be getline getline(file, string); , or using >> file >> x; file >> y; file whatever; , if your data is in a fixed format.

Why are you using gotos?!...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.