Not really. What are you trying to do exactly?
Try not.
Do or do not.
There is no try.
- Master Yoda
well, i have a card program where i would have to sort the deck. I could sort out the numbers but I can't seem to sort out suits (D,C,H,S).Originally posted by Cshot
Not really. What are you trying to do exactly?
For example, my output would be:
H S C D D H C S S D C H ...
1 1 1 1 2 2 2 2 3 3 3 3 ...
Depends on your implementation. You could use numbers for all cards (1-13) to make them sortable, and later convert 1, 11, 12 & 13 to letters (in the output).
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Comparing characters and numbers should almost be the same:
Likewise, you can set all cards to values between 1-52. The suit would depend on the card number range, and the card value would be mod 4. Or you can create a struct with a suit and value attribute. Like what Magos said, you can convert to letters when outputting.Code:int cardValue; char suit; // hypothetical example if(cardValue > 3) // do stuff if(suit > 'H') // do stuff
Try not.
Do or do not.
There is no try.
- Master Yoda