Hey guys! Quick question....when making your card dealing program where it's suppose to have the VALUE(1,2,3,J,Q,K,A), instead a 'T' pops up?
Attached is an example of what I'm talking about....
Hey guys! Quick question....when making your card dealing program where it's suppose to have the VALUE(1,2,3,J,Q,K,A), instead a 'T' pops up?
Attached is an example of what I'm talking about....
How do you define the card values?
What I declared them as? CHAR / character. I'll try changing them to INT.
WRONG MOVE. I ended up getting 55Hearts 65Hearts and a bunch of mumbo jumbo.
Yes. Can you post your character definitions?
Code:int card; char value; char suit; int deck[53]={0}; for (i=1; i<=cards; i++) { int v; do { srand((unsigned)time(NULL)); suit=(card-1)/13+3; card=rand()%52+1; } while (deck[card] !=0); deck[card]=1; v=(card-1)%13+1; switch(v) { case 1: value='A'; break; case 10: value='T'; break; case 11: value='J'; case 12: value='Q'; break; case 13: value='K'; break; default: value=(char)(48+v); break; }
after copying & pasting this part of my program, I figured out why a "T" appears, it's cause I included it into my switch statements. But you can take a look at this code anyways.
I figured it might stand for "ten." (I used zero myself, but that's just preference).
(1) Only use "srand()" once in your program (at the beginning, ideally).
(2) Your "for()" loop has "cards" and not "card"
(3) Your "for()" loop (and "do-while" loop) uses "card" before it is initialized
(4) "i" isn't declared
(5) Your "deck" has 53 cards (for a joker, perhaps?)
(6) I'm too tired to decipher your algorithms, sorry. This should get you started, though.
Yeah, sorry, I should have posted my whole entire program it would have made sense why I had 'cards' instead of 'card', etc. 'cards' corresponds to how many cards the user wants to deal. Thank you for helping!
Oh, and cards start at 2 (the ace is technically the 1).
You're welcome!
Changing the 1 to 2 fixed the whole thing!! THANK YOU BIG TIME. That was the last thing I had to fix for my program.
One problem with using T is, if I see a T of clubs, I'd expect it to be an ace of clubs from a set of Russian playing cards.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.