ok so i want to write a function that fills a deck of cards and then print out the face values and their number or symbol:
Code:
#include <stdio.h>
#include <time.h>
char faces[]={"0023456789TJQKA"};
typedef enum
{
eHearts=3,
eDiamonds,
eClubs,
eSpades
}Cardsuit;
typedef struct
{
char faceValue;
Cardsuit suitValue;
}Card;
void filldeck(Card *);
main()
{
char i;
Card Deck[52];
Card *deckptr;
deckptr=Deck;
filldeck(deckptr);
for(i=0;i<52;i++)
{
printf("%c--%c\n",faces[deckptr->faceValue],deckptr->suitValue);
}
}
void filldeck(Card *deckptr)
{
char i;
char j;
for(i=3;i<7;i++)
{
for(j=2;j<15;j++)
{
deckptr->suitValue=i;
deckptr->faceValue=j;
}
deckptr++;
}
}
this is what comes out:
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
A--¢¾
Is filldeck() wrong or is it my loop that prints out? Thanks for the help