Mi da l'errore "Array subscript is not an integer"
Posto il codice sorgente completo
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CARD 40
#define SUIT 4
#define FACE 10
#define CARD_HAND 3
#define PLAYERS 4
#define BOARD 4 //Cards who remain in the board game at start of game
typedef struct
{
char *suit;
char *face;
}Cards;
typedef struct
{
char name[20];
Cards hand[CARD_HAND];
}Player;
void titolo(void);//CAMBIARE NOME
void insertCards(Cards *deck,const char *suits[],const char *faces[]);
void insertPlayer(Player *wPlayers);
void mescolare(Cards *deck,const char *suits[],const char *faces[]);//DA CAMBIARE IL NOME
void shuttle(const Cards *deck,Player *wPlayers,size_t *x);
int main(void)
{
Cards deck[CARD];
Player players[PLAYERS];
const char *suits[SUIT] = {"ORI","BASTONI","SPADE","COPPE"};
const char *faces[FACE] = {"ASSE","DUE","TRE","QUATTRO","CINQUE","SEI","SETTE","FANTE","CAVALLO","RE"};
int currentCard = 0;
insertCards(deck,suits,faces);
insertPlayer(players);
mescolare(deck,suits,faces);
shuttle(deck,players,¤tCard);
}
void titolo(void)
{
}
void insertCards(Cards *deck,const char *suits[],const char *faces[])
{
size_t x,y,i;
for(x = 0;x < CARD;x++)
{
deck[x].suit = suits[x / FACE];
deck[x].face = faces[x % FACE];
}
}
void insertPlayer(Player *wPlayers)
{
size_t x;
for(x = 0;x < PLAYERS;x++)
{
printf("Enter name %d Player: ",x + 1 );
scanf("%20s",wPlayers[x].name);
}
}
void mescolare(Cards *deck,const char *suits[],const char *faces[])
{
size_t i,x;
srand(time(NULL));
for (x = 0;x < CARD;x++)
{
i = 1 + rand() % CARD;
deck[x].suit = suits[i / FACE];
deck[x].face = faces[i % FACE];
}
}
void shuttle(const Cards *deck,Player *wPlayers,size_t *x)
{
size_t y,n;
for(n = 0;n < PLAYERS;n++)
{
for (x,y = 0;x < (CARD - BOARD) && y < CARD_HAND;x++,y++)
{
wPlayers[n].hand[y].suit = deck[x].suit;
wPlayers[n].hand[y].face = deck[x].face;
}
printf("Cards of %s\n",wPlayers[n].name);
for(y = 0;y < CARD_HAND;y++)
{
printf("%s of %s",wPlayers[n].hand[y].face,wPlayers[n].hand[y].suit);
}
}
}