Does anyone have a good tutorial on howto save an object to file and restore it ?
Does anyone have a good tutorial on howto save an object to file and restore it ?
To save one integer (in text):
Code:void SaveData(int Data) { ofstream WriteFile; WriteFile.open("Save.dat", ios::out); if(!WriteFile.fail()) { WriteFile << Data; WriteFile.close(); } } int LoadData() { ifstream ReadFile; int Data = 0; ReadFile.open("Save.dat", ios::in); if(!ReadFile.fail()) { ReadFile >> Data; ReadFile.close(); } return Data; }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.