Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>#
  4. define CARDS 52
  5. // bitCard structure definitionstruct
  6. bitCard {    
  7. unsigned int face : 4; // 4 bits; 0-15  
  8. unsigned int suit : 2; // 2 bits; 0-3  
  9. unsigned int color : 1; // 1 bit; 0-1}; // end struct bitCard
  10. // new type name Cardtypedef
  11. struct bitCard Card;
  12. // prototypes
  13. void fillDeck(Card *wDeck);
  14. void shuffle(Card *wDeck);
  15. void deal(Card *wDeck2);
  16. int main(void){    s
  17. rand(time(NULL));
  18. // randomize  
  19. Card deck[CARDS];
  20. // create array of Cards  
  21. fillDeck(deck);  
  22. shuffle(deck);  
  23. deal(deck);}
  24. // create 52 cards'
  25. void fillDeck(Card *wDeck){  
  26. // loop 52 times and create cards}
  27. // shuffle
  28. cardsvoid shuffle(Card *wDeck) {    
  29. // loop through deck}
  30. // deal the cards
  31. void deal(Card *wDeck2){  
  32.  // arrays face, suit and color hold all possible string  
  33.  // descriptions of the cards  
  34. char *face[] = { "Ace", "Deuce", "Three", "Four", "Five", "Six",       "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};   char *suit[] = { "Hearts", "Diamonds", "Clubs", "Spades"};  
  35. char *color[] = { "Red", "Black"};
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement