English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
#include
#include

typedef struct
{
char *value;
char *suit;
}card;

void fillDeck(card *Deck, char *Value[], char *Suit[])
{
int i;
for(i=0;i<52;i++)
{
Deck[i].value=Value[i%13];
Deck[i].suit=Suit[i/13];
}
}

void shuffle(card *Card)
{
int i, j;
card temp;
for(i=0;i<52;i++)
{
j=rand()%52;
temp=Card[i];
Card[i]=Card[j];
Card[j]=temp;
}
}

void display(card *Card)
{
int i;
for(i=0;i<52;i++)
printf("%s-%s\t", Card[i].value, Card[i].suit);
}

int main()
{
card deck[52];
char *value[]={"A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"};
char *suit[]={"C", "S", "H", "D"); /*error occurs at this line*/
srand(time(NULL));
fillDeck(deck,value,suit); /*another error occurs at this line*/
shuffle(deck);
display(deck);
}

what's the problem?

2007-03-10 00:33:47 · 3 answers · asked by forgetfulpcspice 3 in Computers & Internet Programming & Design

3 answers

change the line :
"char *suit[]={"C", "S", "H", "D"); /*error occurs at this line*/"
to:
"char *suit[]={"C", "S", "H", "D"}; /*error occurs at this line*/"
you had the wrong bracket at the end

also, you are making your arrays pointer arrays (char *suit[]), just define it as char suit[] (my preference).

change your fillDeck(card *Deck, char *Value[], char *Suit[])
to
fillDeck(card *Deck, char *Value, char *Suit)

try that, it should work

2007-03-10 01:01:31 · answer #1 · answered by justme 7 · 0 0

First error: is it a typo for ")" instead of "}"?

Second error: fix first, because compilers can compound and cascade errors to create another error down the road.

#include
use strcpy() to copy strings; the error seems within fillDeck();

2007-03-10 01:11:03 · answer #2 · answered by Andy T 7 · 0 0

well, your problem is right there, at the ....

i have no idea, why don't you ask a co-worker?

2007-03-10 00:41:36 · answer #3 · answered by Anonymous · 0 2

fedest.com, questions and answers