error: Type mismatch in redecleration on 'throw_cards'

Reply

Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

error: Type mismatch in redecleration on 'throw_cards'

 
0
  #1
Jan 7th, 2008
i have no idea whats wrong with this function =\
  1. void throw_cards(card h_cards[])
  2. {
  3. char f;
  4. cleardevice();
  5. while(f!='f')
  6. {
  7. printf("from 0 to 6 pick the cards you want to thorw\n");
  8. printf("to finish hit 'f'");
  9. f=getch();
  10.  
  11. printf("trowing card %c",f);
  12.  
  13. }
  14. }

i get the error: Type mismatch in redecleration on 'throw_cards'
and it shows me the 2ND line
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 8,313
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 825
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: error: Type mismatch in redecleration on 'throw_cards'

 
0
  #2
Jan 7th, 2008
>error: Type mismatch in redecleration on 'throw_cards'
Post the prototype as well.
In case you were wondering, yes, I do hate you.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,097
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 185
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: error: Type mismatch in redecleration on 'throw_cards'

 
0
  #3
Jan 7th, 2008
char f;
f=getch();
getch returns an int. Therefore, f needs to be of type int.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan stating how a liberal's mind works.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 6,605
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 854
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: error: Type mismatch in redecleration on 'throw_cards'

 
0
  #4
Jan 7th, 2008
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
--
If your code lacks code tags, you will be IGNORED
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

Re: error: Type mismatch in redecleration on 'throw_cards'

 
0
  #5
Jan 7th, 2008
this function works
  1. void check()
  2. {
  3. char e;
  4. e=getch();
  5. if(e=='e')
  6. exit(1);
  7. else
  8. if(e=='s')
  9. start();
  10. else
  11. {
  12. cleardevice();
  13. printf("ERROR:%c unknown\n\nPress\ns to Start game\na to About\ne to Exit",e);
  14. check();
  15. }
  16. }

so i guess i can put
  1. char f;
  2. f=getch();

and Narue what the prototype????

and i have no idea that salem means =\
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,097
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 185
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: error: Type mismatch in redecleration on 'throw_cards'

 
0
  #6
Jan 7th, 2008
>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
  1. int f;
  2. 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:

  1. void throw_cards(card h_cards[])
  2. {
  3. char f;
  4. cleardevice();
  5. while(f!='f')
  6. {
  7. printf("from 0 to 6 pick the cards you want to thorw\n");
  8. printf("to finish hit 'f'");
  9. f=getch();
  10.  
  11. printf("trowing card %c",f);
  12.  
  13. }
  14. }
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.
Last edited by Aia; Jan 7th, 2008 at 2:38 pm.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan stating how a liberal's mind works.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 36
Reputation: dv1r is an unknown quantity at this point 
Solved Threads: 0
dv1r's Avatar
dv1r dv1r is offline Offline
Light Poster

Re: error: Type mismatch in redecleration on 'throw_cards'

 
0
  #7
Jan 7th, 2008
thanks alot Aia
really helped me
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum


Views: 1190 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC