In article <pa****************************@eurobell.co.uk>,
Colin King <ki***@eurobell.co.uk> wrote:
Indeed. It was inspired by Duff's device, however, the beauty of
using a while loop instead of a block { } statement is an amusing
feature which allows me to substitute breaks with continues. :-)
It also allows you to break out of either of two nested switch
statements without a goto:
#include <stdio.h>
int main(int argc, char **argv)
{
int a = atoi(argv[1]), b = atoi(argv[2]);
switch(a) while(0)
{
case 1:
printf("case 1 of outer switch\n");
break;
case 2:
printf("case 2 of outer switch\n");
switch(b)
{
case 1:
printf("case 1 of inner switch\n");
break;
case 2:
printf("case 2 of inner switch\n");
continue;
}
printf("end of inner switch\n");
break;
}
printf("end of outer switch\n");
return 0;
}
-- Richard