Cards* drawCards(int numCards, Cards fullDeck[])
{
Cards *userHand = NULL;
userHand = new Cards[numCards];
int currCard;
for (int i=0; i<numCards; i++)
{
currCard = rand()%52;
if ((fullDeck[currCard].bcardDrawn) = true)
{
while (true)
{
currCard = rand()%52;
if (fullDeck[currCard].bcardDrawn == false)
{
userHand[i] = fullDeck[currCard];
break;
}
}
}
fullDeck[currCard].bcardDrawn = true;
}
return userHand;
}
If I call it as userHand = (2, fulldeck); , it'll draw two card objects and return them to userHand. It'll also mark the card as drawn, so that the card won't be drawn again. However, from what I know, if I access it again to add cards to the hand, those cards will no longer be flagged as drawn because they were modified only within the function's first call.
I figure I need to use pointers to fix this, but how? Do I make an array of pointers pointing to each Cards object and alter those?