I'm trying to create an array of structs, of which the array size is defined by the user in the program. eg. p[0], p[1], p[2].....
typedef struct
{
int score;
}player;
void main()
{
int numPlayers;
printf ("\nEnter number of players (1 - 4)\n");
scanf ("%d", &numPlayers);
}
The problem is I don't know where to go from here. I've tried this, but it says I need to enter a constant value.
player p[numPlayers];
I believe I can use malloc, but I'm quite unsure about how to use it.
Any tips?