newbe needs some help sodoku puzzle
Hello all. I am taking my first class in C and have a professor thats all about having you learn on your own. Anyway Im trying to write a solution to the Sodoku puzzle. What I dont know is how to scan a row for a number that I am trying to enter. professor says I should use an index. I have no clue how to set that up. Here is the part that Where I set up the initial puzzle
Code:
void getGivens(struct sudoCell grid[9][9]) /* User enters starting pattern */
{
int row, col, digit;
char instring[50];
printf("Enter Sudoku pattern line by line.\n");
printf("Enter \'0\' for each undetermined cell\n");
printf("Enter a digit 1..9 followed by a space for each starting cell\n");
for (row=0; row<9; ++row)
{
/* Users dont understand rows numbered 0 */
printf("Enter row %d: ", row+1);
fgets(instring, sizeof(instring), stdin);
sscanf(instring, "%d %d %d %d %d %d %d %d %d",
&grid[row][0].digit, &grid[row][1].digit,
&grid[row][2].digit, &grid[row][3].digit,
&grid[row][4].digit, &grid[row][5].digit,
&grid[row][6].digit, &grid[row][7].digit,
&grid[row][8].digit);
for (col=0; col<9; ++col)
grid[row][col].given = grid[row][col].digit>0;
}
return;
}