A sudoku is valid and a sudoku is solvable are two different things. I am assuming that you are talking only if sudoku is valid or not.
A sudoku is valid if
digits seen in every row, every column and every block are unique ie appeared only once.
each digit is greater then or equal to 1 and less then or equal to 9.
Assume your sudoku is in the form of 9*9 matrix, with few filled characters and few not filled...Following is the sample code (not tested)
bool IsSudokuValid(char board[9][9])
{
bool r[9][9], c[9][9], s[3][3][9];
memset(r, false, sizeof(r));
memset(c, false, sizeof(c));
memset(s, false, sizeof(s));
int number;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (board[i][j] > '0' && board[i][j] <='9') {
number = board[i][j] - '1';
if (r[i][number]) return false;
r[i][number] = true;
if (c[j][number]) return false;
c[j][number] = true;
if (s[i / 3][j / 3][number]) return false;
s[i / 3][j / 3][number] = true;
}
}
}
return true;
}