solved  goto statements

shadowvillian (71)   Link to this post
i have a question about goto statements. i have a program with a loop with multiple if statements inside. i got rid of the loop and started it with - begin main: - then at the end of the if statements i put - goto begin main; -. will this work? its all in the same int main() block but the goto begin main(s) are in the if blocks.
helios (6077)   Link to this post
So you willfully traded good practice for bad practice?
shadowvillian (71)   Link to this post
i was just trying to take new things i learn and use them. i was having run time errors and this seemed to use less code. i was i wanted to make it would and the book im reading only gave me about 2 paragraphs of info on it.
Duoas (3505)   Link to this post
It probably uses more code. The compiler knows how to make loops nice and tight. When using goto, you throw away all kinds of optimization information.

remember:
Google around "goto" and you'll learn why there were only two paragraphs on it in your book. Hopefully one of those paragraphs plainly stated that goto is almost never the right thing to do.

goto remember;
shadowvillian (71)   Link to this post
ya i got rid of them in the code. my compiler was giving me errors and stuff so i guess ill just stick to the loop.

This topic is archived - New replies not allowed.