I am trying to create a simple poker game Texas Hold'em style with c.
At first, I tried to create a deck of cards with 2 char
arrays:
char *suits_str[4] = {"Spades", "Hearts", "Diamonds", "Clubs"};
char *faces_str[13] = {"2", "3", "4", "5", "6", "7", "8", "9", "10",
"J", "Q", "K", "A"};
Problem
Everything went well, it was pretty simple to represent the cards. But when it come to analyzing the hands to determine the winner, it seems like using char type values was a pretty bad idea.
So I want to change the data type of the cards into int
:
- Suits:
0="Clubs", 1="Diamonds", 2="Hearts", 3="Spades"
- Faces:
0="2", 1="3", 11="King", 12="Ace"
Example:
int suits[4] = {0, 1, 2, 3};
int faces[13] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
But now I don't know how to convert those int values back into their matching string values of the cards.
Question
What is the correct and simple approach to represent the cards using int
Arrays?