Breaking out of several nested loops

Rick Buls buls at ssc-vax.UUCP
Thu Oct 4 07:45:23 AEST 1984



>> The correct way to break out of multiply nested control constructs (using the
>> example in the referenced article) without using 3 separate boolean flags is:
>> 
>> 	i=1;
>> 	while(...){
>> 		...
>> 		for(...;...;...){
>> 			...
>> 			switch(...){
>> 				...
>> 				goto Out;
>> 			}
>> 		}
>> 	}
>> Out:	i=2;
>> 
>> 

	Very UNstructured!!!!!!!!!!

	Try the following:
   	i=1;
	struct(????);
	i=2;
	...
struct(????)
	...
{
	...
   	while(...){
   		...
   		for(...;...;...){
   			...
   			switch(...){
   				...
   				return;
   			}
   		}
   	}
}
   


   where ???? is what ever parameters are needed!!!!



More information about the Comp.lang.c mailing list