Apr 3, 2009 at 4:59pm UTC
I understand it's used in loops, but how exactly?
Can you give me example on how to use it, like:
1 2 3 4
cout << "asks user to input a number" ;
cin >> number;
if (number == 0) { "loop above part"
}
That is just example how i'd want things to go, ask a question and the answer cannot be 0, otherwise it asks again and again until 'number != 0'
EDIT: i'm just a newbie so far, just to inform.
Last edited on Apr 3, 2009 at 5:00pm UTC
Apr 3, 2009 at 5:35pm UTC
I just took a look at that and noticed goto statement and gave it a shot and it worked :)
I probably didn't get to 'goto' in tutorial im following, so thanks :)
Apr 3, 2009 at 5:43pm UTC
Now you have to tell me whats wrong with goto? :(
it works fine.... :D
Apr 3, 2009 at 5:50pm UTC
It's just less structured, makes the code more complicated to read. I admit, I've used gotos before. Normally for when I have nested loops and I need to break from all the loops and I'm too lazy to make another variable to be checked for and allow multiple breaks.
Apr 3, 2009 at 8:37pm UTC
If you plan on getting a job, forget about goto. Goto makes debugging a massive pain in the a**.
Apr 3, 2009 at 8:50pm UTC
The only good thing of goto
is that you never really need it