Is this legal becuase it does not work, the file is created according to the argument passed into the function ok but after closing it is blank, if i do it without the if statements it works fine.
Code:
void SolBoard::SaveGame(int myfile)
{
ofstream Gamefile;
if(myfile == 0) //which file to write over.
ofstream Gamefile("mysave0.txt");
if(myfile == 1)
ofstream Gamefile("mysave1.txt");
if(myfile == 2)
ofstream Gamefile("mysave2.txt");
for(countclick = 0; countclick < 49; countclick++)
{
Gamefile << moves_record[moves][countclick];
Gamefile<< " ";
}
Gamefile.close();
}