I have to initialize a two-dimensional array, but the specific wording is confusing me:
a game_state variable is created and pointed
to by the first parameter. Each element in
the board table is created empty
The array has to be initialised in an initialiser function:
void init_game_state(game_state* gp)
And is first created by:
struct game_state_int {
int board[DIMENSION][DIMENSION];
};
With dimension being defined as '4'. Is it as simple as going:
void init_game_state(game_state* gp)
{
*gp = (game_state)malloc(sizeof(struct game_state_int));
for (int i = 0; i < DIMENSION; i++)
{
for (int j = 0; j < DIMENSION; j++)
{
(*gp)->board[i][j] = NULL;
}
}
As I've tried this and have been getting odd results with the rest of the program.