Help with strings and array......

Say, I make an array of playing cards called Deck[52] from a structure, and then below main I initialize string faceValue ={Ace, Two, Three, Four, Five, etc....}. How can i pull data from that sting and place it into an array. Ive thought about using pointers, but Im not 100% sure about how to really do that....So, my question is how can i use string data with arrays?
Last edited on
What are you actually trying to do (i.e., how you are trying to implement the deck from a high-level perspective)? It is certainly possible to have arrays of strings, but I'm not sure if this is really all you actually need:
string faceValues[] = {"Ace", "Two", /* ... */};
This is of course an implementation of one of my last threads, but rather than actually copy verbatim. I want to learn how to do this. The idea I had was wondering if i could take the data that is stored in the string variable ie....ace,two,three,etc and place it in a box of an array of 52 playing cards called Deck[52].

If this helps...Ive included my output logic (how I want it to look when I get done with it....

Output Logic:
The inital starting cards are:
------------------------------
Players Hand [??][5D]
Dealers Hand [??][3C]

Player's Turn :
--------------------
Player's current hand: [8H][5D] (13 points)
Player chooses to draw
Player's current hand: [8H][5D][H4] (17 points)
Player chooses to draw
Player's current hand: [8H][5D][H4][10J] (27 points)
Player busted at 27!

Dealer's Turn :
--------------------
Dealer's current hand: [3S][3C] (6 Points)
Dealer chooses to draw
Dealer's current hand: [3S][3C][4C] (10 Points)
Dealers chooses to draw
Dealer's current hand: [3s][3c][4C][8D] (18 Points)

Player's Score:
---------------
Player's Score: 27
Dealer's Score: 18

We are asked to create a card structure, then create a deck(array) of cards for all 52 cards, then populate the deck(array) with all 52 cards (suit and card) using a loop, etc....Ive put some work into it....Been reading up on many different approaches I could take, but unfortunately my brain is completely smashed right now, and Im just getting input on what someone with more experience might suggest. It's a regular Blackjack game (regular house rules)....

There are other processes that I am trying to figure out. Like take the computer not knowing what the value of a playing card is, or what card suit the card is. So, I created a struct to define what a card is then after int main () I started creating string's to determine face value, card status, card suit, points value (1 or 11 = Ace, Face Value = 10 (10,J,K, Q), and all other values 2-9......My logic is player chooses card (that being random to him) (face up/face down does not matter) then player is asked to either hit or stick. If player hits, the card drawn, if player sticks then no card drawn, and during each cyle the value of the cards is being added, so the end result is knowing the players true points value. The same principle applies to dealer (w/ the exception of house rules).....
Last edited on
Topic archived. No new replies allowed.