What am I doing wrong? I'm getting gcc compiler error on line 29.
card.c: In function `main':
card.c:29: warning: passing arg 1 of `deal' from incompatible pointer type
Code:
/* Figure 7.24 from chapter 7 */
/* Card shuffling dealing program */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* prototypes */
void shuffle( int wDeck[][ 13 ] );
void deal( const int wDeck[][ 13 ], const char *wFace[],
const char *wSuit[] );
int main( void )
{
/* initialize suit array */
const char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" };
/* initailize face array */
const char *face[ 13 ] =
{ "Ace", "Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King" };
/* initialize deck array */
int deck[ 4 ][ 13 ] = { 0 };
srand( time( 0 ) ); /* seed random-number generator */
shuffle( deck ); /* shuffle the deck */
deal( deck, face, suit ); /* deal the deck */
return 0; /* indicates successful termination */
} /* end main */
/* shuffle card in the deck */
void shuffle( int wDeck[][ 13 ] )
{
int row; /* row number */
int column; /* column number */
int card; /* counter */
/* for each of the 52 cards, chose slot of deck randomly */
for ( card = 1; card <= 52; card++ ) { /* start for */
/* choose new random location until unoccupied slot found */
do {
row = rand() % 4;
column = rand() % 13;
} while( wDeck[ row ][ column ] != 0 ); /* end do...while */
} /* end for */
} /* end function shuffle */
/* deal cards in deck */
void deal( const int wDeck[][ 13 ], const char *wFace[],
const char *wSuit[] )
{ /* start function deal */
int card; /* card counter */
int row; /* row counter */
int column; /* column counter */
/* deal each of the 52 cards */
for ( card = 1; card <= 52; card++ ) { /* start for */
/* loop through of wDeck */
for ( row = 0; row <= 3; row++ ) { /* start for */
for ( column = 0; column <= 12; column++ ) { /* start for */
/* if slot contains current card, display card */
if ( wDeck[ row ][ column ] == card ) { /* start if */
printf( "%5s of %-8s%c", wFace[ column ], wSuit[ row ],
card % 2 == 0 ? '\n' : '\t' );
} /* end if */
} /* end for */
} /* end for */
} /* end for */
} /* end function deal */