Player *player[NUMBER_PLAYERS]; // it's an array of pointers,
-> Any item in the array needs to point to a Player before you use it
typedef struct match
{
card *list; // it's a pointer
struct match *next;
} Match;
-> card *list is also needs to point to an initialized card
#include <stdio.h>
#include <stdlib.h>
#define NUMBER_PLAYERS 6
typedef unsigned int uint;
typedef struct
{
uint suit;
uint rank;
} Card;
typedef struct card
{
Card card;
struct card *next;
} card;
typedef struct match
{
card *list;
struct match *next;
} Match;
typedef struct
{
char *name;
uint wins;
uint losses;
Match *match;
} Player;
void main(void)
{
Player player[NUMBER_PLAYERS];
card cardList[NUMBER_PLAYERS];
uint i;
for(i = 0; i < NUMBER_PLAYERS; i++)
{
player[i] = NULL;
printf("Name: ");
scanf("%[^\n]s%*c", &player[i].name);
printf("\n\n");
player[i].name;
player[i].losses = 0;
player[i].wins = 0;
player[i].match->next = NULL;
player[i].match.list = &cardList[i];
player[i].match.list->next = NULL;
}
getchar();
}