Simple problem, I hope...

Discussion in 'Mac Programming' started by Polaris84, Feb 23, 2011.

  1. Polaris84 macrumors newbie

    Joined:
    Feb 23, 2011
    #1
    Hi, I'm new to programming in general and I'm attempting to write a text based game of black jack for a bit of practice. I've just started the project and run into something weird that I really can't explain. So far all I'm doing is defining a function that creates a data structure database for each individual card and having the main function print the suit and a number value corresponding to how many "cards" are in the deck. When it prints, it looks like this:

    Code:
    h deckValue = 1
     deckValue = 1
    \304 deckValue = -1809827132
    \206 deckValue = -1605732986
    \206 deckValue = -1605732986
     deckValue = 2139062143
    h deckValue = 32639
    h deckValue = 8
    h deckValue = 9
    h deckValue = 10
    h deckValue = 11
    h deckValue = 12
    h deckValue = 13
    d deckValue = 14
    d deckValue = 15
    d deckValue = 16
    d deckValue = 17
    d deckValue = 18
    d deckValue = 19
    d deckValue = 20
    d deckValue = 21
    d deckValue = 22
    d deckValue = 23
    d deckValue = 24
    d deckValue = 25
    d deckValue = 26
    c deckValue = 27
    c deckValue = 28
    c deckValue = 29
    c deckValue = 30
    c deckValue = 31
    c deckValue = 32
    c deckValue = 33
    c deckValue = 34
    c deckValue = 35
    c deckValue = 36
    c deckValue = 37
    c deckValue = 38
    c deckValue = 39
    s deckValue = 40
    s deckValue = 41
    s deckValue = 42
    s deckValue = 43
    s deckValue = 44
    s deckValue = 45
    s deckValue = 46
    s deckValue = 47
    s deckValue = 48
    s deckValue = 49
    s deckValue = 50
    s deckValue = 51
    s deckValue = 52
    I can't figure out why it spits back junk for cards 2 - 7 and then proceeds to print correctly. Any ideas?
     
  2. flashy-cat macrumors regular

    flashy-cat

    Joined:
    Apr 8, 2007
    Location:
    UK
  3. bux macrumors regular

    Joined:
    Apr 22, 2004
    Location:
    Sweden
    #3
    To me it looks as if they aren't assigned, but not much to say without actual source code.
     
  4. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    1. We can't read your mind, and we can't see your code on MacRumors. So we can't say what you are doing wrong.

    2. If something doesn't work as intented, chances are 99.9999% that it is your fault.

    3. When something is wrong, it is very, very often not where you think it is wrong.

    Combining these three: Post complete code that shows up the problem. Always post exactly the code that shows the problem by copying and pasting it, NEVER type in the code or modify it in any way because you might change exactly the bit that is wrong.
     
  5. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #5
    To further what gnasher729 said, read this http://mikeash.com/getting_answers.html and make sure you are providing the right info and asking the right question to get the answers you seek.

    B
     

Share This Page