我正在制作一个解决一个数独游戏的程序,但我收到了一个错误,从我的编译器.
error: invalid use of undefined type ‘struct Square’
30 | if(box->squares[x]->possible[number-1] == 0){
^~
功能是:
int updateBoxes(Square *** sudoku, int row, int column){
int x;
int number = sudoku[row][column]->number;
Box * box;
box = sudoku[row][column]->box;
for(x = 0; x < SIZE_ROWS; x++){
if(box->squares[x]->possible[number-1] == 0){
box->squares[x]->solvable--;
box->squares[x]->possible[number-1] = 1;
}
}
return 1;
}
错误也出现在后面两行.
Square
和Box
的定义是:
typedef struct box
{
struct Square ** squares; /* array of Squares */
int numbers;
int possible[9];
int solvable;
struct Box * next;
} Box;
/* square is a single number in the board */
typedef struct square
{
int number;
int possible[9];
/*
the array is only made of 0 and 1
each index corresponds to a number: ex: index 4 == number 5 ...
1 tells me that 5 cannot go into this scare
0 tells me that 5 can go into this scare
*/
int solvable; /* will be subtracted 1 each time and when it is 1 it's because is solvable */
Box * box; /* tells me the corresponding box */
int row;
int column;
} Square;
我在YouTube上遵循一个教程,这个家伙没有得到我得到的错误,YouTube视频是: https://www.youtube.com/watch?v=CnzrCBLCDhc&t=1326s