i have this function for dealing cards in card game. it is working fine, but i cant figure out how to pass a variable in it. Here is what i mean: This function will deal 5 card. but the user should have the option to change 1 or multiple cards WHILE keeping the other cards. how can i modify this function to do this task?
void deal( int deck[][13], int hand[][2], char *suit[], char *face[] )
{
int r = 0; /* counter for position in the hand */
int card, row, column; /* loop counters */
printf( "The hand is:\n" );
/* loop to distrubute the cards */
for ( card = 1; card < 6; card++ )
for ( row = 0; row <= 3; row++ )
for ( column = 0; column <= 12; column++ )
if ( deck[ row ][ column ] == card )
{
hand[ r ][ 0 ] = row;
hand[ r ][ 1 ] = column;
printf( "%5s of %-8s\n", face[ column ], suit[ row ] );
++r;
} /* end if */
printf( "\n" );
} /* end function deal */
here are the strings im using:
int deck[ 4 ][ 13 ]; /* represents deck of cards */
int hand1[ 5 ][ 2 ]; /* represents hand */
char *face[ 13 ] = { "Ace", "Deuce", "Three", "Four", "Five",
"Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" };
thanks for any help!!!