while(condition) { switch(some_var) { case 'y': do_something(); break;
case 'x': goto end; break; } }
end:
Is this something not very advisable to do? Well at least that is what an author suggested.. in my short experience I can firmly say that it doesnt look so clean on my code..
It's horrible. You mean this:
looping = 1; while( looping && condition) { switch(some_var) { case 'y': do_something(); break;
case 'x': looping = 0; break; } }
Ok, very nice BUT... if I have something done after the switch that I want to skip... while(condition) { char z; int first=0; z=getchar(); getchar(); switch(z) { case 'a': first=1; break; case 'z': goto end; /* cause I dont want it tu print the message */ break; } if(first) /* I dont want spend CPU cycles with this, just to jump over it.. */ puts("You typed the first letter of the alphabet"); } I know this is pretty ugly code and could be fixed in other ways, but I can assure the there are situations that look like this.. so what would you suggest for replacing goto here, if you have a very strong need to skip some part of you loop..
'looping' should obviously be replaced with a variable name describing the reason you need to continue round the loop.
-- "...our desktop is falling behind stability-wise and feature wise to KDE ...when I went to Mexico in December to the facility where we launched gnome, they had all switched to KDE3." - Miguel de Icaza, March 2003
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists/archive/suse-programming-e