Can I just allocate memory for this struct without allocating memory for each individual item inside it (in C)?
typedef struct _game {
int grid[SIZE][SIZE];
int array[10];
Player player[MAX_PLAYERS];
int currentPlayer;
} game;
Where these are in a separate header file (and player is a struct implemented in the same file as the game):
typedef struct _game *Game;
typedef struct _player *Player;
I'm just wondering, when I create a new instance of a game, do I need to allocated memory (with calloc or malloc for exmaple) for each player in the game (4 players)? I thought that since I have an array of players (or pointers to players) in the game struct already (and this array size isn't changing) then I would only need to allocate memory for the game struct itself. Is this the case? How is memory allocation used? And specifically how is it used with structs? Do I need to allocated memory for all other items in the struct as well?