pointers to modify objects in array?

I'm trying to create a blackjack game, and so I need to let the user draw further cards. I'm having a problem with this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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?
When you pass the array in, it is actually modifying the array outside of the function as well since it is passed as a pointer.
Topic archived. No new replies allowed.