0

I'm trying to make a deck of cards to use in a blackjack game but I'm having problems.

#include <stdio.h>
#include <math.h>
#include <string.h>
main(){
int i;
typedef struct {
int rank, suit;
} cardtype;

cardtype deck[52];
cardtype hand[5];



char *rank[13] = {"ace", "Duece", "3", "4", "5", "6", "7", "8", "10", "Jack", "Queen", "King"};
char *suit[4] = {"Clubs", "Diamonds", "Hearts", "Spades"};


for(i=1; i < 52; i++){             //this is the part that i'm having trouble with
rank[deck[i].rank] = rank[i%13-1]; //I didn't really know how to do it so i just 
suit[deck[i].suit] = suit[i/13];}  //experimented, probably gibberish lol        


//for(i=0; i < 52 ; i++)
//{print("%s of %s", rank[deck[i].rank], suit[deck[i].rank]);};


return 0;

}

any help would be much appreciated thanks!!

3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by abhimanipal
0

This should help you get started

for each suite i: 1...4
for each card j:1 ... 13
// Now set the properties for the card

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.