•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 428,288 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,651 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1368 | Replies: 3 | Solved
![]() |
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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. c Syntax (Toggle Plain Text)
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
Last edited by ~s.o.s~ : Nov 3rd, 2006 at 11:43 am. Reason: Added code tags. Learn to use them.
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,226
Reputation:
Rep Power: 38
Solved Threads: 937
Please read my signature and follow the link
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Jun 2005
Location: Novi Sad, Serbia
Posts: 273
Reputation:
Rep Power: 6
Solved Threads: 29
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,226
Reputation:
Rep Power: 38
Solved Threads: 937
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- 2D array allocation problem (C)
- joining array, but still read as number (ASP)
- Array length (C++)
- sending part of array (C)
- 3d to 1d Array Conversion (C++)
- C++ Array Question (C++)
- Declaring an array of records in MC++ (C++)
- assignment operator for a 3d array (C++)
- Help with copying an array into a struct (C)
Other Threads in the C++ Forum
- Previous Thread: Assignment operator help
- Next Thread: how to save two int values into two columns of excel file? and how toread them again



Linear Mode