views:

425

answers:

1
int check_row;
    for (n=0; n<9; n++) {
 used_numbers[n] = n+1;
}
for (row=0; row<3; row++) {
    for (check_row=0; check_row<3; check_row++) {
        used_numbers[(sudoku[row][check_row]-1)] = 0;
    }
...

int sudoku[9][9] declared as global variable and used_numbers[9] as int. In sudoku matrix for row from 0 to 2 and col from 0 to 2 for each row, has in it, numbers > 0

At this point I get "Floating point exception", how resolve this? sorry for my bad english...

+3  A: 

It is a very bad idea to have function/variable definitions in a header file, like you have done. Put the definitions in a C file, and the declarations in a header file for other C files to use.

Your floating-point error is on line 66 of sudoku.h, not where you think it is.

number = rand()%m;

Since m is zero here, dividing by it results in the error.

I haven't looked at the whole code in detail.

Alok
yeah, I have resolved now, thanks for the answer.. :)