Thread: A question for those who have made a card dealing program....

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    A question for those who have made a card dealing program....

    Hey guys! Quick question....when making your card dealing program where it's suppose to have the VALUE(1,2,3,J,Q,K,A)A question for those who have made a card dealing program....-t-png, instead a 'T' pops up?
    Attached is an example of what I'm talking about....

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    How do you define the card values?

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    What I declared them as? CHAR / character. I'll try changing them to INT.

  4. #4
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    WRONG MOVE. I ended up getting 55Hearts 65Hearts and a bunch of mumbo jumbo.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Yes. Can you post your character definitions?

  6. #6
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    Code:
    	int card;
    	char value; 
    	char suit; 
    	int deck[53]={0};
    
    for (i=1; i<=cards; i++)
    {
    
      int v; 
      do {
    	srand((unsigned)time(NULL));
        suit=(card-1)/13+3;
        card=rand()%52+1;
      }
    
    while (deck[card] !=0);
    deck[card]=1;
    v=(card-1)%13+1;  
    
    
    	switch(v)
    	{
    	case 1:
    		value='A';
    		break;
    	case 10:
    		value='T';
    		break;
    	case 11:
    		value='J';
    	case 12:
    		value='Q';
    		break;
    	case 13:
    		value='K';
    		break;
    	default:
    		value=(char)(48+v);
    	break;
    	}

    after copying & pasting this part of my program, I figured out why a "T" appears, it's cause I included it into my switch statements. But you can take a look at this code anyways.

  7. #7
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I figured it might stand for "ten." (I used zero myself, but that's just preference).

    (1) Only use "srand()" once in your program (at the beginning, ideally).
    (2) Your "for()" loop has "cards" and not "card"
    (3) Your "for()" loop (and "do-while" loop) uses "card" before it is initialized
    (4) "i" isn't declared
    (5) Your "deck" has 53 cards (for a joker, perhaps?)
    (6) I'm too tired to decipher your algorithms, sorry. This should get you started, though.

  8. #8
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    Yeah, sorry, I should have posted my whole entire program it would have made sense why I had 'cards' instead of 'card', etc. 'cards' corresponds to how many cards the user wants to deal. Thank you for helping!

  9. #9
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Oh, and cards start at 2 (the ace is technically the 1).

  10. #10
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    You're welcome!

  11. #11
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    Changing the 1 to 2 fixed the whole thing!! THANK YOU BIG TIME. That was the last thing I had to fix for my program.

  12. #12
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    One problem with using T is, if I see a T of clubs, I'd expect it to be an ace of clubs from a set of Russian playing cards.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help with Card Dealing Program
    By Izzy123 in forum C++ Programming
    Replies: 5
    Last Post: 03-28-2011, 01:39 PM
  2. Need help with a card dealing program using classes
    By nick753 in forum C++ Programming
    Replies: 25
    Last Post: 11-24-2010, 10:25 PM
  3. Please help! Stuck on card dealing program.
    By Randoon in forum C Programming
    Replies: 3
    Last Post: 11-22-2002, 08:05 PM
  4. Card Dealing program help
    By Randoon in forum C Programming
    Replies: 1
    Last Post: 11-13-2002, 08:27 PM
  5. card shuffling dealing question
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2002, 08:37 PM

Tags for this Thread