![]() |
| ||
| Having trouble with a else... else if loop (For a class) My code, in 'full' (only 89 lines, lol) is here. My input file is here and (for kicks and giggles) my outuput file when I comment out the else... if statements and have simply fout is here. (Remove the .txt on the last two...) I'm having a problem with my if else statement. When I comment out the else if stuff, it works. (Choice is an int) if (choice == 1) Is is supposed to be something like <= and not ==? Choice does either equal 1 or 2, and if it is 3 it skips all of them to the end. But the above code skips over them, even though for it to get out of the while loop it HAD to work. Does it have something with the preceding do while loop? doI'm sure I made a stupid mistake... indeed, for a while It did not work: I was giving choice the value of 2 or 1 each time! ( else if (choice = 2)) Thanks for the help! I have this due tomorrow, so no matter what I'll be getting it done. I hate getting all of the work (I know easy for some of you, but I'm a beginner) and then something simple stupid not letting it work. And I KNOW a switch would work, but the prof does not want one! I name my files funny, by the way. The name of the project? Poppus_of_sorrowz. I believe I have more fun making the name than the code itself... although making kickbutt code, above and beyond what the professor wants, is fun. But I'm going for KISS (Keep it simple, stupid) for now, as I don't have time for very pretty code, with extra stuff (as much as I would like to do that! School can be a pain, so much to study for! |
| ||
| Re: Having trouble with a else... else if loop (For a class) um. yeas. So I DID NOTHING to the code, except let a friend look at it and uncomment the hated stupid section... and it worked. Stupid. Thanks for looking! |
| ||
| Re: Having trouble with a else... else if loop (For a class) Don't ever ever try to get cute with your code. Professors really seriously hate that. |
| ||
| Re: Having trouble with a else... else if loop (For a class) I think you have not included iostream or have not written using namespace std; |
| All times are GMT -4. The time now is 4:20 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC