I've written a sudoku solver before, but I should mention that I wrote it out of my head without doing any research first. I'm reasonably good at solving sudoku puzzles, but I'm sure you'd find more waterproof methods if you looked around.
Anyway, the method I used went something like this. I represented all of the data in the puzzle as a two-dimensional array, and applied various algorithms to the puzzle until it was solved or the puzzle was unchanged (in which case the program wasn't good enough to solve it). The algorithms would be strategies that you might use when solving a sudoku puzzle by hand; e.g., if eight of the nine numbers in a row are filled out, then the last number is whichever number does not appear in the row.
As I said, it's a reasonably good method, but not perfect. For one thing, it doesn't completely model how a human sudoku-solver will think. A lot of the thought process goes something like this: "if I put this 7 here, would it create an impossibility?" Here an "impossibility" is something like two 7's in the same quadrant, column, or row. If it is impossible, you rule out that move, which narrows down your choices; maybe since the 7 can't go there, it has to go somewhere else. And so on.
I never did look at a "real" sudoku-solving program. There are lots of them online that profess to be able to solve any sudoku puzzle (which is certainly possible). If you want more ideas you could see how some of them work.
Well, here I was talking about automatically solving sudoku puzzles. You'll have to forgive me if that's not what you want, since you haven't been very clear on that point. Are you just trying to create a sudoku game that ensures that every move the player makes is a valid one?
That's pretty easy. When the user asks to place a '7' in a particular spot, you just scan that row and column for other sevens, and that quadrant too. I'm not sure if "quadrant" is quite the right word, but you know what I mean. Here's the sort of code you might use.
Code:
/** Check to see if the user made a valid move. The user is assumed to have
attempted to place the number @a number at position @c data[x][y].
*/
int is_valid_move(int data[9][9], int x, int y, int number) {
/* The x and y coordinates of the upper-left corner of the quadrant
in which the position (x, y) lies.
*/
int qx = (x / 3) * 3, qy = (y / 3) * 3;
int i, j;
for(i = 0; i < 9; i ++) {
/* check this column */
if(data[x][i] == number) return 0;
/* and this row */
if(data[i][y] == number) return 0;
}
/* check this quadrant */
for(int i = 0; i < 3; i ++) {
for(int j = 0; j < 3; j ++) {
if(data[qx + i][qy + j] == number) return 0;
}
}
/* The number wasn't duplicated in the column, row, or quadrant;
therefore, this must be a valid move.
*/
return 1;
}
That assumes you use -1 or something to represent a square which has not been given any number.
Anyway, enough blathering. If you want more help you'd better describe what you're trying to do.