   Saving Games
  How would I have an option in a text-based rpg to save your game.  I have some understanding of fout and fin but not much.  I want something on the lines of creating a .txt file that holds information like how much money playerX has.  Thank you.   
ArticleOut:ofstream fout("data.txt");fout << PlayersMoney;fout.close();In:ifstream fin("data.txt");fin >> PlayersMoney;fin.close();   ;  thanks for replying so quickly.  would I need to #include anything? also would i just put like 5000 in data.txt? another question, how would i use the same .txt for multiple variables (or would i have to create a new .txt for each variable).  thanks a lot for the help   ;  File Streeams, theres an fstream tutorial at gametutorials.com in the c++ secion.but in breif.#include <fstream>#include <stdlib.h>using namespace std;char* str = "This goes in the file!";char* str2;char tempstr[256];int main(int argc, char* argv[]){ofstream pFileOut("file.txt", ios::out); //set up our output filepFileOut<<str; //output strpFileOut.close();ifstream pFileIn("file.txt", ios::in);while(!pFileIn.eof()) //not end of file{pFileIn.getline(tempstr, 256); //readsprintf(str2, "%s %s", str2, tempstr); //make sure its all coppied into str2}pFileIn.close();}There more handwritten masterpiece code [joking there might be an error, but im sure someone would catch it]Quote:Original post by mxma1thanks for replying so quickly.  would I need to #include anything? also would i just put like 5000 in data.txt? another question, how would i use the same .txt for multiple variables (or would i have to create a new .txt for each variable).  thanks a lot for the helpAnd to answer this, you can store as many valuses as you want in data.txt before you pFile.close(); it.   ;  Just be sure you include whitespace between each stored variable so that it doesn't look like one gigantic number when you come back to read it in (assuming your writing in text mode and not binary mode).   ;  Or you could use Xml [wink]It'll give you more control over your structure of the save file whilst keeping it human readable.TinyXml