Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Because you almost don't need it. However, there are some situation where where it can be handy. For example, two loops:
for(...)
(for(...)
{ ...
if ( fault )
goto error
}
..
error: /do something/
If you used BREAK it would only stop one loop, the deepest one.
Generally it is just overused, and I think if you want to use it do it only if necessary.
Regards,
IanP
It is not preferred because you will lose track of program flow. It gives the programmer the power to "goto" any program location as and when he likes, even invalid ones, without firing off any errors. For a small program, it is easy to keep track of program flow. But for larger applications, you will get lost in debugging work in no time.
There is nothing wrong in go to but it is mainly assembly language convention so ethically not preferred in C. Otherwise people still use go to where they need explicit control and i think sometimes it's a powerful thing under conditional jumps. Excessive use is bad because it may cause the program to wrongfully jump if there is any logical error in the decision of go to.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.