Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>#
- define CARDS 52
- // bitCard structure definitionstruct
- bitCard {
- unsigned int face : 4; // 4 bits; 0-15
- unsigned int suit : 2; // 2 bits; 0-3
- unsigned int color : 1; // 1 bit; 0-1}; // end struct bitCard
- // new type name Cardtypedef
- struct bitCard Card;
- // prototypes
- void fillDeck(Card *wDeck);
- void shuffle(Card *wDeck);
- void deal(Card *wDeck2);
- int main(void){ s
- rand(time(NULL));
- // randomize
- Card deck[CARDS];
- // create array of Cards
- fillDeck(deck);
- shuffle(deck);
- deal(deck);}
- // create 52 cards'
- void fillDeck(Card *wDeck){
- // loop 52 times and create cards}
- // shuffle
- cardsvoid shuffle(Card *wDeck) {
- // loop through deck}
- // deal the cards
- void deal(Card *wDeck2){
- // arrays face, suit and color hold all possible string
- // descriptions of the cards
- char *face[] = { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"}; char *suit[] = { "Hearts", "Diamonds", "Clubs", "Spades"};
- char *color[] = { "Red", "Black"};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement