I'm trying to make a solitaire game using structs and linked lists, I've started with reading cards from a file with colours and it's values, so I have a problem with such cards as 'A
', 'J
', 'D
', 'K
'
their values are to be set to 1, 11, 12, 13
respectively. How do I do this in case of using following construction:
#define J 11
typedef struct card {
char color[15];
unsigned int value;
struct card* pnext;
struct card* pprev;
} cardsStruct;
struct card* pstart = NULL;
struct card* plast = NULL;
int main()
{
FILE *myFile;
cardsStruct card;
if ((myFile = fopen("Cards.txt", "rb")) == NULL)
return -1;
while (!feof(myFile)){
fscanf(myFile, "%s %u", card.color, &card.value);
printf("%s %u\n", card.color, card.value);
}
fclose(myFile);
return 0;
}