Passing an array to a function c++ -


i'm trying pass array function called printdeck, , working fine until added things print function. here declaration , call printdeck, along calls other functions work fine:

void filldeck(card *deck); void printdeck(card deck[]); void printdeck(card p1[]); void printdeck(card p2[]); void shuffledeck(card *deck);  int main (int argc, char *argv[]){    card deck[52];    card p1[26];    card p2[26];    filldeck(deck);    shuffledeck(deck);    printdeck(deck); //this problem happening    printdeck(p1);  //and here    printdeck(p2);  //and here  } 

the error "undefined reference `printdeck(card*)'" 3 of printdeck function calls. feel making stupid mistake , cant see it, looks fine me? i've looked syntax passing arrays functions , thought doing perhaps not. if needed, here actual function:

void printdeck(card deck[], card p1[], card p2[]){    for(int = 0; < 52; i++){       printf("%d of %s",deck[i].number,deck[i].suit);        printf("\n\n");        //printf("%s", deck[i].suit);       //printf("\n%d\n\n", deck[i].number);    }    printf("\n\np1's cards\n");    for(int = 0; < 52; i++){       printf("%d of %s", p1[i].number, p1[i].suit);    }    printf("\n\np2's cards\n");    for(int = 0; < 52; i++){       printf("%d of %s", p2[i].number, p2[i].suit);    } } 

any appreciated thanks!

these 3 lines:

void printdeck(card deck[]); void printdeck(card p1[]); void printdeck(card p2[]); 

declare same function. equivalent saying:

void printdeck(card []); void printdeck(card []); void printdeck(card []); 

if want print decks in 1 function call, need change function declaration to:

void printdeck(card [], card [], card []); 

and change calling lines from:

printdeck(deck); printdeck(p1); printdeck(p2); 

to

printdeck(deck, p1, p2); 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -