+ 3

How to use “goto”?

Can anyone tell me how to use “goto”? By the way, what are the advantages and disadvantages of “goto”? You can take either C++ or Java for example, for I can only use these two, thank you!

9th Jan 2018, 6:01 AM
Oscar Jin
Oscar Jin - avatar
1 Resposta
+ 7
ex. int i = 5; goto test; i = 0; test: i++; // i = 6 pro: quick way for jump some line of code, exit from nested loop without particular condition. con: goto makes difficult to trace the control flow of a program, making the program hard to understand and hard to modify
9th Jan 2018, 6:34 AM
AtoMX
AtoMX - avatar