Hi,
I'm making a program to play a pretty simplified blackjack game. I need to use abstract data types and am having a bit of trouble.
At the moment i am just trying to create a deck of cards.
I have a structure for the deck of cards and a structure for each card. (as shown)
I'm trying to create a function to fill my deck structure with card structures so that the deck is filled with 52 standard cards.
This is what i have so far:
This is my card structure
Code:
enum card_suit { HEARTS, DIAMONDS, CLUBS, SPADES };
enum card_value { ACE = 1, JACK = 11, QUEEN = 12, KING = 13 };
typedef struct
{
enum card_value value;
enum card_suit suit;
int face_up;
} card_t;
And this is my deck structure:
Code:
#define MAX_CARDS_IN_DECK 52
typedef struct
{
card_t deck[MAX_CARDS_IN_DECK];
} deck_t;
And this is my function to try fill the deck:
Code:
deck_t create_deck(deck_t deck)
{
int i,j;
deck_t * deck_ptr;
deck_ptr = deck; //I think this is the problem but im not sure how to fix it
for (i = 0; i < 4; i++)
{
for (j = 1; j < 14; j++)
{
deckptr -> value = j;
deckptr -> suit = i;
deckptr++;
}
}
}
Please help.
Chris.