Im reading C: How to Program and I have got up to pointers, one of the examples shown goes with a deck of cards and shuffles then displays the 52 cards.
I am having an error in the main function with the pointers.
Is the code I am currently using, the error message is thisCode:#include <stdio.h> #include <stdlib.h> #include <time.h> void shuffle(int [][13]); void deal(const int [][13], const char *[], const char *[]); main() { char *suit[4] = {"Hearts","Diamonds","Clubs","Spades"}; char *face[13] = {"Ace","Deuce","Three","Four", "Five","Six","Seven","Eight", "Nine","Ten","Jack","Queen","King"}; int deck[4][13] = {0}; srand(time(NULL)); shuffle(deck); deal(deck,face,suit); return 0; } void shuffle(int wDeck[][13]) { int card, row, column; for (card=1;card<=52;card++) { row = rand()%4; column = rand()%13; while (wDeck[row][column] != 0) { row = rand()%4; column = rand()%13; } wDeck[row][column]=card; } } void deal(const int wDeck[][13], const char *wFace[], const char *wSuit[]) { int card, row, column; for (card=1;card<=52;card++) for (row=0;row<=3;row++) for (column=0;column<=12;column++) if (wDeck[row][column]==card) printf("%5s of %-8s%c", wFace[column], wSuit[row], card % 2 == 0? '\n' : '\t'); }
If its too any help I am using gccdeck.c: In function `main':
deck.c:21: warning: passing arg 1 of `deal' from incompatible pointer type
deck.c:21: warning: passing arg 2 of `deal' from incompatible pointer type
deck.c:21: warning: passing arg 3 of `deal' from incompatible pointer type



LinkBack URL
About LinkBacks



