|
-
May 12th, 2009, 02:12 PM
#7
Re: Problem with functions
 Originally Posted by jcnewton
I think i fixed it a little bit?
Code:
cin>>numPlayers[20];
No. You're not understanding arrays. Declaring an array such as
int numPlayers[20];
means you have 20 integers. You generally access them one at a time through an index. Valid indexes are 0 through 19. numPlayers[20] is invalid memory. I'm not even sure why you're making numPlayers an array as it appears you only need that number once.
I know you're all gung ho on functions, but you're not there yet. Go reread the chapter on arrays. The program as written would most likely crash.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|