crash - Beginner programmer; program instantly closes on switch (C++) -
I am walking around with your very basic C ++ knowledge of programming (for two days) I am trying to write a program that calculates the user input around the PHI (1.61803399). Here's the code, if it's a mess: However, when you enter a number on the first signal (1-4), program crashes only on the desktop, and why can not convince me. Your program does not stop at the switch statement when I drive; I though I would get to the second text some problems that I get: First, the faster ones attention, equally return turned out the application instead of the response output . Secondly, code to cure instead of return, you want to put in "break"; So you do not run the code in any condition after the current situation. Third, you might want to add the option to turn Goto into an input loop and leave it in your menu. It's more of a stylish choice, but I think you'll find that it's difficult to debug in Goto's C / C ++ in the future. -Edit: For formatting- OK, thinking that you want to be able to do more than one task in running the program, and to get rid of Goto, you can do something like this. :
#include
Skip boolean = false; Do {cout & lt; & Lt; "1) Menu item 1" & lt; & Lt; Andal & lt; & Lt; "2) Quit" & lt; & Lt; Endl; Cin.get (user options); Switch (userchoice) {case 1: cot and lt; & Lt; "Please enter the input for option 1:"; Cin & gt; & Gt; user input; Cout & lt; & Lt; Case1function (userInput); break; Case 2: Skip = True; break; Default: cout & lt; & Lt; "Please read the menu" & lt; & Lt; Endl; }} While (leaving!);
Comments
Post a Comment