I have this expression:
const int numPlayers = 2;
player players[numPlayers];
This is an array of user-defined type players (using struct). However, I get an error saying that numPlayers
has to be a constant value.
expression must have a constant value
What am I doing wrong?
I have also initialized the array like this:
player *players = (player*)calloc(sizeof(player), numPlayers);
But I cannot access any of the local variables of the struct without the program crashing.