User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Sep 2006
Posts: 4
Reputation: RichC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RichC RichC is offline Offline
Newbie Poster

trying to point to an array

  #1  
Nov 2nd, 2006
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.
  1. void DeckOfCards::deal()
  2. {
  3. // initialize suit array
  4. static const char *suit[ 4 ] =
  5. { "Hearts", "Diamonds", "Clubs", "Spades" };
  6.  
  7. // initialize face array
  8. static const char *face[ 13 ] =
  9. { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven",
  10. "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
  11.  
  12. // for showing fist five cards dealt
  13. for ( int card = 1; card <= 5; card++ )
  14. {
  15. // loop through rows of deck
  16. for ( int row = 0; row <= 3; row++ )
  17. {
  18. // loop through columns of deck for current row
  19. for ( int column = 0; column <= 12; column++ )
  20. {
  21. // if slot contains current card, display card
  22. if ( deck[ row ][ column ] == card )
  23. {
  24. cout << setw( 5 ) << right << face[ column ]
  25. << " of " << setw( 8 ) << left << suit[ row ]
  26. << ( card % 2 == 0 ? '\n' : '\t' );
  27. } // end if
  28. } // end innermost for
  29. } // end inner for
  30. } // end outer for
  31. } // end function deal
  32.  
  33. int main()
  34. {
  35. DeckOfCards deckOfCards; // create DeckOfCards object
  36.  
  37. deckOfCards.shuffle(); // shuffle the cards in the deck
  38. deckOfCards.deal(); // deal the cards in the deck
  39. deckOfCards.faceValue = *face;// palces value of *face into array faceValue
  40. deckOfCards.pair(); // displays text if hand holds a pair
  41. return 0; // indicates successful termination
  42. } // end main
Last edited by ~s.o.s~ : Nov 3rd, 2006 at 11:43 am. Reason: Added code tags. Learn to use them.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,226
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 38
Solved Threads: 937
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: trying to point to an array

  #2  
Nov 2nd, 2006
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
Reply With Quote  
Join Date: Jun 2005
Location: Novi Sad, Serbia
Posts: 273
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Rep Power: 6
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: trying to point to an array

  #3  
Nov 3rd, 2006
Originally Posted by Ancient Dragon View Post
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
If you want to win, you must not loose (Alan Ford)
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,226
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 38
Solved Threads: 937
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: trying to point to an array

  #4  
Nov 3rd, 2006
Originally Posted by andor View Post
You made a little mistake with your link. No big deal just test it and U will understand


Thanks -- its corrected now.
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 5:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC