I am trying to create a simplified version of the Rummy card game. I need to parse in the card abbreviations for example SA is Spades Ace. DT is Diamond 10 etc. I know there is an easier way to do this but that's how my assignment wants it done.
The sample execution would look like
rummy 3 S2 H9 C4... etc. include all 52 cards.
The number in argv[1] is the players in the game. How am I supposed to take the cards starting after the number and put them into an array?
My code so far
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int players = *argv[1];
char deck[52];
int i, j, pid, cid;
if (players > '5' || players < '3')
{
printf("%c is not the allowed number of players, min is 3 and max is 5\n",*argv[1]);
exit(0);
}
}
argv[1]is a pointer to"3",argv[2]is a pointer to"S2"etc. You should get familiar with strings and pointers.