www.thecareerplus.com
The CareerPlus
Home Technical Resources Programming Expressions
Thursday 09th September 2010
 
 
Should we use goto or not?

Discuss it!          

You should use gotos wherever it suits your needs really well. There is nothing wrong
in using them. Really.
There are cases where each function must have a single exit point. In these cases,
it makes much sense to use gotos.
myfunction() { if(error_condition1) { // Do some processing. goto failure; } if(error_condition2) { // Do some processing. goto failure; } success: return(TRUE); failure: // Do some cleanup. return(FALSE); } Also, a lot of coding problems lend very well to the use of gotos. The only argument
against gotos is that it can make the code a little un-readable. But if its commented
properly, it works quite fine.

Discuss it!          

CrackTheIntervew.NET
Advertisement
 
Top! Top!