Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char *values[13]= {
- "ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "Jack", "Queen", "King"
- };
- struct Card {
- int suit;
- int value;
- char values[10];
- };
- void fillDeck(struct Card deck [52]) {
- int count = 0;
- for (int h = 0; h <4;h++)
- for (int i = 0; i < 13;i++, count++){
- deck[count].suit = h;
- deck[count].value=i;
- strcpy(deck[count].values, values[i]);
- }
- }
- void printDeck(struct Card deck [52]) {
- for (int i = 0;i<52;i++){
- printf("%d - %s\n", deck[i].suit, deck[i].values[i]);
- }
- }
- int main(){
- struct Card deck[52];
- fillDeck(deck);
- printDeck(deck);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement