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!!

My psychic powers aren't working well. The problem I got was it made the coffee too bitter.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.