Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

goto considered harmless

Name: Anonymous 2018-05-10 11:02

I was reading Bjarne Stroustrup's sepples book and found this

One of the few sensible uses of goto in ordinary code is to break out from a nested loop or
switch-statement (a break breaks out of only the innermost enclosing loop or switch-statement).
For example:


void f()
{
int i;
int j;
for (i = 0 ; i <n ; i ++)
for (j = 0 ; j <m ; j ++) i f (nm [i][j ] == a ) goto found ;
// not found
// ...
found :
// nm[i][j] == a
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List