I have the following code for a Sudoku game but it is not solving the board correctly. Also the output files doesn't have the solution or the initial matrix stored in them. What can I change in the code to make it solve the board correctly without adding the same number on the same row and column and to store the initial board and the solution in the txt files?
An instance of this class is used in a QAbstratTableModel class that helps me to generate the grid and has a solveSudoku method that calls methods from SudokuGenerator.cpp, but the method is not solving the sudoku board correctly.
Here is the main class
#include "SudokuGenerator.h"
#include "QVector"
int main() {
SudokuGenerator sudokuGenerator(1);
sudokuGenerator.umplu();
sudokuGenerator.scrie_initial();
sudokuGenerator.scrie_solutie();
sudokuGenerator.scrie_curent();
int** gridData;
QVector<QVector<int>> solution(9, QVector<int>(9));
for (int i = 0; i < 9; ++i) {
for (int j = 0; j < 9; ++j) {
if (gridData[i][j] != 0) {
solution[i][j] = gridData[i][j];
} else {
solution[i][j] = sudokuGenerator.get_matrice()[i][j];
}
}
}
}