Breaking out of several nested loops (& ANSI C)
Charlie Martin
crm at duke.UUCP
Wed Oct 10 22:55:54 AEST 1984
I may be dense, but I simply cannot see what makes
label: while ( cond )
{
...
if ( break cond )
break label ;
}
any more
structured'' than
while( cond )
{
...
if ( break cond )
goto end ;
}
end : ;
In addition, the construct above has the advantage that it
looks like it is doing what it is really doing -- that is, the
break label'' version says that it is breaking a loop labellled
label'', which label is at the beginning, but it is effectively
GOING to the END.
Don Knuth wrote an article that was pretty good on Structured
Programming With GOTO's that covered all off this sort of
thing, by the way -- I can dig up a formal reference if needed.
Charlie Martin
(...mcnc!duke!crm)
More information about the Comp.lang.c
mailing list