Is it possible to save global variable values into a save. Then load them back into memory as the same global variables later to save ur current state in a game?
yeah thats what i was currently testing but the header i forget which one if or of wont load with include im using fstream out that should work fine no?
yeah thats what i was currently testing but the header i forget which one if or of wont load with include im using fstream out that should work fine no?
Could you rephrase this? I don't understand what you are asking.
also what i want to keep track of in the save file is
intergers
bools
strings
for the most part so far
What do you mean keep track?
Could you post an example or some code.
What i was saying is that one of the #include <ifstream> or <ofstream> cant be found when i compile. <fstream> loads though and it works for in and out.... so im fine with fstream alone for #include?
Second im keeping track of global variables ints for keeping track of calculations player level etc.... bools for true/false if you have been to a certain place, or if you have an item equipped and so on, and strings for names of different items and playername etc.
Well it saved the file but it saved it as one continuous file how the heck is it going to know where 1 piece of data ends and another starts... how to i make it save each piece of data on the next line?
What i was saying is that one of the #include <ifstream> or <ofstream> cant be found when i compile. <fstream> loads though and it works for in and out.... so im fine with fstream alone for #include?
There are no header files called ifstream or ofstream. ifstream and ofstream classes are both in the fstream header.
Second im keeping track of global variables ints for keeping track of calculations player level etc.... bools for true/false if you have been to a certain place, or if you have an item equipped and so on, and strings for names of different items and playername etc.
I'm still not sure I understand you. You probably have to come up with some sort of format, in which you save your variables to a file, and follow the same format when reading back. For example saving each variable in it's own line, then reading it back in the same order.
EDIT: I just saw your huge code post: You probably have to start using arrays.
how to i make it save each piece of data on the next line?
Thanks alot. And I have not learned arrays yet im building a fully functional minus grahpics text based console rpg!! This is an awesome learning experience for me and its pretty fun, granted its outdated but its more for the old styleness is what makes it so great.
I'm getting this weird error in compiler on the LoadGame()
error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ostream'
doh! i totally missed that i used a text pad to replace all the << to >> to make it fast and i missed that one xD i feel a homer simpson moment coming on!!! nice catch
hey btw i never did figure out the bug to my combat algorithms think you could take a look and see if you could figure it out its 1 tiny little problem, the script works but not exactly as intended