well i followed the following path...
Code:
while(true) //To Open/make new game.
{
ifstream Rd("save.dat");
if(!Rd)
{
GameHistory();
MakeNewGame();
clrscr;
break;
}
Rd>>Name;
Rd>>Cash;
cout<<"Welcome back "<<Name<<", you have $"<<Cash<<" in your pocket\n";
break;
and then in MakeNewGame
Code:
void MakeNewGame()
{
string Name;
int Cash;
cout<<"What is your name?\n";
cin>>Name;
Cash=100;
ofstream Wrt("save.dat");
Wrt<<Name<<'\n';
Wrt<<Cash;
Wrt.close();
cout<<"Thank You "<<Name<<"! Saved game has been created!\n";
cout<<"You have $"<<Cash<<" in your pocket.\n";
}
And this works quite good...
Now what i need to know, is this a decemt way to do it, or can anyone reconmend a better way...
I am trying to keep
int main()
{
...
}
as short as possible