Iron Chef Pontiff Posted March 3, 2004 Share Posted March 3, 2004 Well Im in need of some help. For some reason Im not able to get this program to run for class. Ill post the code and maybe someone can give me a clue as to what Im missing. The purpose of the program is in the menu. Sorry no notes. http://www.playnintendo.com/boards/phpBB2/...p?p=10588#10588 Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted March 3, 2004 Share Posted March 3, 2004 Well Im in need of some help. For some reason Im not able to get this program to run for class. Ill post the code and maybe someone can give me a clue as to what Im missing. The purpose of the program is in the menu. Sorry no notes. http://www.playnintendo.com/boards/phpBB2/...p?p=10588#10588 Array indexing starts at 0, not 1, and goes to the array dimension -1 So, declaring an array like this... int array[4]; and using it like this... array[4] = 0; Will cause your program to crash. The last element of the array is array[3], and the first element is array[0]. You seem to be accessing the last element as array[4] in several places in your code, so that's one thing to fix. Cheers A Quote Link to comment Share on other sites More sharing options...
Iron Chef Pontiff Posted March 3, 2004 Author Share Posted March 3, 2004 I changed that. I get my menu and prompt to enter a selection but after I enter the selection I dont get the prompt to enter the number of rows. I think I have all of my cout statements correct. Is it maybe a problem with the switch or while statement? Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted March 3, 2004 Share Posted March 3, 2004 I changed that. I get my menu and prompt to enter a selection but after I enter the selection I dont get the prompt to enter the number of rows. I think I have all of my cout statements correct. Is it maybe a problem with the switch or while statement? This is happening because you input selection as a character, so when you press the key 1, the character '1' is stored in the variable. This is definitely not the same as the VALUE 1. From memory, character 1 has value 49 in ASCII. Change your switch statement to case '1': and elsewhere where you do that sort of checking. Cheers A PS: You're aware I'm $150 an hour? Quote Link to comment Share on other sites More sharing options...
Iron Chef Pontiff Posted March 3, 2004 Author Share Posted March 3, 2004 That did it. Boy do I feel dumb. Thanks for the help. How would you like me to pay? Remember Im a poor starving college student. Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted March 3, 2004 Share Posted March 3, 2004 That did it. Boy do I feel dumb. Thanks for the help. How would you like me to pay? Remember Im a poor starving college student. Respect your elders, help those in need when you can, and one day when you're an expert in your field remember that once you, too, were a newbie needing help. Cheers A Quote Link to comment Share on other sites More sharing options...
Iron Chef Pontiff Posted March 3, 2004 Author Share Posted March 3, 2004 Sounds fair. Thank you. Quote Link to comment Share on other sites More sharing options...
EricBall Posted March 4, 2004 Share Posted March 4, 2004 Array indexing starts at 0, not 1, and goes to the array dimension -1 Although this is true for C and C++, some languages use array indicies of 1 to n. Trying to write to (and sometime read from) array elements outside of these bounds can cause problems. (Trust me, I one had a bug in a program which wrote to array[-1]. It took a long time to figure it out because the program didn't crash until it exitted.) We havent even looked at the libraries yet. Ahh, but you have. stdlib is a C library with a bunch of functions. cin & cout are part of the C++ iostream library. Quote Link to comment Share on other sites More sharing options...
Iron Chef Pontiff Posted March 5, 2004 Author Share Posted March 5, 2004 So much information. So little memory. Its gonna take me lots of practice and questions. Once I have this down then I can move on to Basic and Atari programing. All I need is Andrew's book. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.