I'm creating a Sudoku game, and would like to save to board contents to a file. I have it to work with a known file name, but would like to be able to specify a file name, to save the data to.
Here is the routine I'm trying to use for loading, but it's not compiling. Could someone let me know where, or what, the problem is??
void Save_Game(int sudoku_board[][9], int start_board[][9])
{
int i,j;
string File_Name,Sudoku_Name;
//ofstream outfile("C:\\Users\\whitenite1\\Documents\\Visual Studio 2008\\Projects\\Sudoku_Game\\Sudoku_game.dat");
// Loads if I use the above, instead of the asking for file name section, below
gotoXY(20,15, "Please give the file, a name..");
cin >> Sudoku_Name;
File_Name = "C:\\Users\\whitenite1\\Documents\\Visual Studio 2008\\Projects\\Sudoku_Game\\" + Sudoku_Name + ".dat";
ofstream outfile(File_Name);
for (i=0;i<9;i++)
{
for ( j=0;j<9;j++)
{
outfile << sudoku_board[j][i] << " ";
}
outfile << endl;
}
outfile << endl;
for (i=0;i<9;i++)
{
for ( j=0;j<9;j++)
{
outfile << start_board[j][i] << " ";
}
outfile << endl;
}
outfile.close();
}
Thanks. I tried it out, and the file saved. Of course.. ;) So, this //ofstream outfile("C:\\Users\\whitenite1\\Documents\\Visual Studio 2008\\Projects\\Sudoku_Game\\Sudoku_game.dat"); is then a cstring? Because it saved as is. One last question, if I may. I am wanting the user to be able to see all the .dat files in the directory, so one can be chosen to be loaded into the grid. Is finding the files as easy as the saving, was?