ok so i changed my function to a backtracking function (which i found online). It still reads from a file and inputs it in an array, the check function is working properly so i haven't changed that. If your wondering the following is the puzzle I'm trying to solve (where zeros are empty spaces).
0 5 0 0 2 0 0 7 0
7 2 0 4 0 3 0 0 0
9 0 0 0 5 0 6 2 0
0 0 5 0 8 6 0 0 0
1 0 0 0 4 0 0 0 8
0 0 0 2 3 0 4 0 0
0 9 3 0 1 0 0 0 2
0 0 0 3 0 2 0 4 6
0 8 0 0 0 0 0 1 0
// backtracking function
void Sudoku::solvePuzzle()
{
int x = 0;
int y = 0;
int r = 0;
bool back_flag;
while (r < 81) {
back_flag = true;
x = r/9;
y = r%9;
for(int num = arr[x][y]; num < 10 && back_flag; num++) {
if(check(x,y,num)) {
arr[x][y] = num;
back_flag=false;
break;
}
else if(num >= 9) {
arr[x][y] = 0;
}
}
if(back_flag) {
r--;
}
else {
r++;
}
}
}