I am making a Black Jack card game and I am using a structure to hold the player cards and information however when I go to redeal a new hand i need to zero out the old hand otherwise it just keeps adding cards. I am trying to use memset to zero out just the particular member variable arrays but for some reason it still just keeps the same values from the previous hand.
Code:
struct Players
{
char name[MAX_PLAYERS][80];
char *card[MAX_PLAYERS][MAX_HAND]; //card names
char *suit[MAX_PLAYERS][MAX_HAND]; //card suits
int value[MAX_PLAYERS][MAX_HAND]; //point value of cards
int index[MAX_PLAYERS][MAX_HAND]; //index number of cards in hand
int total_cards[MAX_PLAYERS]; //total number of cards in hand
int Aces[MAX_PLAYERS]; //number of Aces in hand
int Money[MAX_PLAYERS]; //total winnings
int Bet[MAX_PLAYERS]; //current bet amount
};
code i am using to try to zero out the member arrays
memset(&players.Aces ,0,sizeof(players.Aces[MAX_PLAYERS] ));
memset(&players.Bet ,0,sizeof(players.Bet[MAX_PLAYERS] ));
memset(&players.card ,0,sizeof(players.card[MAX_PLAYERS][MAX_HAND] ));
memset(&players.index ,0,sizeof(players.index[MAX_PLAYERS][MAX_HAND] ));
memset(&players.suit ,0,sizeof(players.suit[MAX_PLAYERS][MAX_HAND] ));
memset(&players.total_cards ,0,sizeof(players.total_cards[MAX_PLAYERS]));
memset(&players.value ,0,sizeof(players.value[MAX_PLAYERS][MAX_HAND] ));