i have no idea whats wrong with this function =\

void throw_cards(card h_cards[])
   {
     char f;
     cleardevice();
     while(f!='f')
      {
       printf("from 0 to 6 pick the cards you want to thorw\n");
       printf("to finish hit 'f'");
       f=getch();

	 printf("trowing card %c",f);

      }
   }

i get the error: Type mismatch in redecleration on 'throw_cards'
and it shows me the 2ND line

{

Recommended Answers

All 6 Replies

>error: Type mismatch in redecleration on 'throw_cards'
Post the prototype as well.

char f;
f=getch();

getch returns an int. Therefore, f needs to be of type int.

Trying to call it before you prototype it will cause the compiler to declare it implicitly.
This implicit declaration will almost certainly conflict with the actual definition you provide later on.

this function works

void check()
   {
     char e;
     e=getch();
     if(e=='e')
	exit(1);
     else
     if(e=='s')
	start();
     else
     {
      cleardevice();
      printf("ERROR:%c unknown\n\nPress\ns to Start game\na to About\ne to Exit",e);
      check();
     }
   }

so i guess i can put

char f;
f=getch();

and Narue what the prototype????

and i have no idea that salem means =\

>so i guess i can put

char f;
f=getch();

I quote those to point out what I was referring to. In fact, you should change every variable that is going to hold the return of getch() to type int.
e.g

int f;
f = getch();

Now you can use that one. That's the proper way.

>and Narue what the prototype????

If you code this function after the main function:

void throw_cards(card h_cards[])
   {
     char f;
     cleardevice();
     while(f!='f')
      {
       printf("from 0 to 6 pick the cards you want to thorw\n");
       printf("to finish hit 'f'");
       f=getch();

	 printf("trowing card %c",f);

      }
   }

The prototype would be a signature of this function placed somewhere before the call of it.
This signature would be:
void throw_cards(card h_cards[]);
Basically you make a copy of the function header and add a ; at the end of it, and place it before being called in main or other function; that way the compiler knows what to expect at compilation time.

>and i have no idea that salem means =\
If you didn't know what a prototype was; of course you wouldn't understand what he's saying.

thanks alot Aia
really helped me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.