I currently have a program that writes Sudoku boards to files; however, I would like the program to be able to read the board already in the file, copy it and then add another board to the file. It follows, then, that if there were two boards in the file, both boards would be copied and a third would be added to the file.
Currently, my code deletes the data already in the file and writes a new board to the file. I would like to remedy this. Can anyone suggest a function that can help solve this problem?
void WriteFile(int Board[9][9])
{
ofstream SudokuBoard;
SudokuBoard.open ("1.txt");
for (int row = 0; row <= 8; row++)
{
SudokuBoard << endl;
for (int column = 0; column <= 8; column++)
{
SudokuBoard << Board[column][row]; // prints horizontally.
}
}
SudokuBoard.close();
}