Simple Syntax Error, yet I can't see it - C -
updated version of question
thank help. have 1 more error left
i took advice , post code has error:
expected declaration or statement @ end of input:
this code:
void cards(void) { char suits[4][9] = { "hearts", "diamonds", "clubs", "spades"}; for(i=0; i<size; i++) { if(i%13 == 0 || i%13 == 10 || i%13 == 11 || i%13 == 12) printf("%s ", facecheck(i%13) ); else printf("%d ", i%13+1); printf("of %s \n", suits[i/13]); }; }
original version of question
i have rather simple error can't seem see. it's driving me nuts because have finish before end of night. if more eyes on appreciate it.
also know there other errors want try fix without before ask help.
the error in line 8 , 71 regarding shuffle. comes error: expected ';', ',' or ')' before numeric constant can't see made error that.
#include <stdio.h> #include <string.h> #include <stdlib.h> #define size 52 enum faces{ace = 0, jack = 10, queen, king}; char * facecheck(int d); void shuffle( int deck[], int size); int main() { int deck[size], i, n; char suits[4][9] = { "hearts", "diamonds", "clubs", "spades" }; srand( time( null ) ) ; for(i = 0; < size; i++) { deck[i] = i; i++; }; for(i = 0; < size; i++) { if(i%13 == 0 || i%13 == 10 || i%13 == 11 || i%13 == 12) printf("%s ", facecheck(i%13) ); else printf("%d ", i%13+1); printf("of %s \n", suits[i/13]); } return 0; } char * facecheck(int d) { static char * face[] = { "ace", "jack", "queen", "king" }; if(d == ace) return face[0]; else { if(d == jack) return face[1]; else { if(d == queen) return face[2]; else { if(d == king) return face[3]; } } } } void shuffle(int deck[], int size) ; { int i, j, temp; for(i = 0; < size; i++) { j = rand() % size; temp = deck[i]; deck[i] = deck[j]; deck[j] = temp; } }
you using parameter name size
, #define size 52
. here size resolve 52. hence error
also on line 71:
void shuffle( int deck[] , int size )
same issue.
one more thing:
you have ;
after void shuffle( int deck[] , int size )
following piece of code {}
not execute.
Comments
Post a Comment