I was trying to do a program that analyzes poker hands, however I am extremely confused and I don't know where to start. The suits are represented by the letters C
(clubs), D
(diamonds), H
(hearts) and S
(spades).
The value of the cards is represented by the numbers and the letters A
(ace), 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
, T
(ten), J
(jack), Q
(queen) and K
(king).
The program is supposed to receive input like AS KC QC JH 9D
.
But the difficult part is that it should be able to receive 5, 7, 9 or 10 cards (strings with 2 chars).
Note: each card is made of two chars (example: 2C
).
Thank you in advance :)
I will offer incremental suggestions in this answer:
To determine how many cards are in the hand/set: you can call strlen(string)
to count the number of characters in the string.
Once you know how many cards are there, you can use a switch
statement: switch(number_of_cards) { ... }
to branch the processing logic into distinct case
s.