goto myLabel
...
myLabel:
/* code */ In these simple and limited programming languages, goto may be used quite commonly, and this feature is included in C/C++ too. It is however, considered extremely bad practice.
The reason for this is simply that there are better alternatives. C and C++ provide more advanced control structures like various types of functions and loops, which not only make it easy to code a certain behavior, but safer. goto is still sometimes used for customized control, like breaking out of heavily nested loops.
It has been said that if your program does indeed require the use of goto, you should probably be redesigning the whole program to fix it properly instead of using a quick fix like goto.
If in doubt, don't use goto.
Author : Sean
0 nhận xét:
Post a Comment