Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Polaris84

macrumors newbie
Original poster
Feb 23, 2011
2
0
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?
 
To me it looks as if they aren't assigned, but not much to say without actual source code.
 
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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.