In a header file -- gameboard.h -- I have a struct named gameboard. In this struct I declare square **squares
, where squares is the following: typedef enum {EMPTY, RED_COIN, YELLOW_COIN} square;
In gameboard.c, I have a function that allocates memory for a 2D array. In this function I declare gameboard* result
.
Question: When creating the initial array, i.e. the part of a 2D that will store an array, why can't I do this:
result->squares = malloc(numRows * sizeof(result->square*));
More specifically, why is square an invalid type?