I've got a structure of this type :
#define SUDOKU_SIZE 9
typedef struct {
int grid[SUDOKU_SIZE][SUDOKU_SIZE];
} sudoku_t;
But when I want to create one : struct sudoku_t sudo;
I got this error : error: storage size of ‘s’ isn’t known
Thanks
I've got a structure of this type :
#define SUDOKU_SIZE 9
typedef struct {
int grid[SUDOKU_SIZE][SUDOKU_SIZE];
} sudoku_t;
But when I want to create one : struct sudoku_t sudo;
I got this error : error: storage size of ‘s’ isn’t known
Thanks
By using typedef, you create a new type; you can simply reference it by its name sudoku_t (instead of struct sudoku_t). So instead of struct sudoku_t s; write
sudoku_t s;
If for some reason you actually want to create a named struct, drop the typedef:
struct sudoku_t {
int grid[SUDOKU_SIZE][SUDOKU_SIZE];
};
int main() {
struct sudoku_t s;
}