I have been trying to store the values of card face value into an array called faceValue but I don't know how to do this. I've created the array and placed in public in my h.file (char faceValue[5];) but trying to link it to *face in the function deal is where I'mhaving trouble. Could someone look at what I've done and tell me what I'm doing wrong.

void DeckOfCards::deal()
{
   // initialize suit array
   static const char *suit[ 4 ] = 
      { "Hearts", "Diamonds", "Clubs", "Spades" }; 

   // initialize face array
   static const char *face[ 13 ] = 
      { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", 
      "Eight", "Nine", "Ten", "Jack", "Queen", "King" };

   // for showing fist five cards dealt
   for ( int card = 1; card <= 5; card++ )
   {
      // loop through rows of deck
      for ( int row = 0; row <= 3; row++ )
      {
         // loop through columns of deck for current row
         for ( int column = 0; column <= 12; column++ )
         {
            // if slot contains current card, display card
            if ( deck[ row ][ column ] == card ) 
            {
               cout << setw( 5 ) << right << face[ column ] 
                  << " of " << setw( 8 ) << left << suit[ row ]
                  << ( card % 2 == 0 ? '\n' : '\t' );
            } // end if
         } // end innermost for
      } // end inner for
   } // end outer for
} // end function deal 

int main()
{
   DeckOfCards deckOfCards; // create DeckOfCards object
   
   deckOfCards.shuffle(); // shuffle the cards in the deck
   deckOfCards.deal(); // deal the cards in the deck
   deckOfCards.faceValue = *face;// palces value of *face into array faceValue
   deckOfCards.pair(); // displays text if hand holds a pair
   return 0; // indicates successful termination
} // end main

Recommended Answers

All 3 Replies

Please read my signature and follow the link

Please read my signature and follow the link

You made a little mistake with your link. No big deal just test it and U will understand :)

You made a little mistake with your link. No big deal just test it and U will understand :)

Thanks -- its corrected now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.