-
okay, i have taken all considerations and have done this so far,i printed my code and output but it still isnt working how i want it to
thanks
code
Code:
void filldeck(Card *deckptr)
{
char x;
char y;
for(x=3;x<7;x++)
{
for(y=2;y<14;y++)
{
deckptr -> suitValue = x;
deckptr -> faceValue = y;
}
deckptr++;
}
return;
}
void shuffledeck(Card *deckptr)
{
Card temp[52];
int x, y, m = 52 / 2;
for (x = 0, y = 0; x < 52; x += 2, y++)
{
temp[x] = deckptr[y];
temp[x + 1] = deckptr[m + y + 1];
}
for (x = 0; x < 52; x++)
deckptr[x] = temp[x];
return;
}
void dealdeck(Card *deckptr , Card handsDealt [4][5])
{
int i;
char faces[]={"023456789TJQKA"};
printf("\n");
for(i=0;i<5;i++)
{
printf("%26c of %c, \n",faces[deckptr[i].faceValue], deckptr[i].suitValue);
}printf("\n");
for(i=0;i<5;i++)
{
printf("%c of %c, ",faces[deckptr[i].faceValue], deckptr[i].suitValue);
printf("%43c of %c, \n",faces[deckptr[i].faceValue], deckptr[i].suitValue);
}
printf("\n");
for(i=0;i<5;i++)
{
printf("%26c of %c, \n",faces[deckptr[i].faceValue], deckptr[i].suitValue);
}printf("\n");
return;
}
output
Code:
A of ♥,
A of ♦,
A of ♣,
A of ♠,
╠ of ╠,
A of ♥, A of ♥,
A of ♦, A of ♦,
A of ♣, A of ♣,
A of ♠, A of ♠,
╠ of ╠, ╠ of ╠,
A of ♥,
A of ♦,
A of ♣,
A of ♠,
╠ of ╠,
-
Code:
void filldeck(Card *deckptr)
{
char x;
char y;
for(x=3;x<7;x++)
{
for(y=2;y<14;y++)
{
deckptr -> suitValue = x;
deckptr -> faceValue = y;
}
deckptr++;
}
return;
}
you still have a problem with this function.
Do you have a debugger at all? Can you step through this code and see why you are ending up with a deck of just the four aces?
As I said before look at this code and think about how many times deckptr++; is called. Which loop is it in and how many times is that loop executed? These are the question you should be asking yourself.
-
okay when i move the deckptr++ into the loop for the cards the numbers change but the sit value stay the same??? Sorry but i am at a loss to debugging my program!?! Why is this so hard??
Code:
void filldeck(Card *deckptr)
{
char x;
char y;
for(x=3;x<7;x++)
{
for(y=2;y<14;y++)
{
deckptr -> suitValue = x;
deckptr -> faceValue = y;
deckptr++;
}
}
return;
}
output
Code:
3 of ♥,
4 of ♥,
5 of ♥,
6 of ♥,
7 of ♥,
3 of ♥, 3 of ♥,
4 of ♥, 4 of ♥,
5 of ♥, 5 of ♥,
6 of ♥, 6 of ♥,
7 of ♥, 7 of ♥,
3 of ♥,
4 of ♥,
5 of ♥,
6 of ♥,
7 of ♥,
-
hey hey before anyone responds I FIGURED IT OUT!!!
thank you everyone for ur help, ill prob be hearing from u next week again :)