A perverse switch statement.

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Sat Oct 14 06:39:44 AEST 1989


In the example below it makes the code even more obscure to add a
conditional break within the for in the switch in the for. See below
after "case 1"

In article <FLEE.89Oct13095510 at shire.cs.psu.edu>, flee at shire.cs.psu.edu (Felix Lee) writes:

|  main()
|  {
|  	int i, j = 1;
|  	for (i = 0; i <= 6; ++i)
|  		switch (i)
|  		top:
|  		case 6:	{
|  			int k = 3;
|  		case 0:	for (; ++k % 3; ++j) {
|  		case 1:		printf(" j = %d,", j);
				if (i == 4) break;
|  		case 2:		printf(" k = %d\n", k);
|  			}
|  		case 3: printf("i = %d\n", i); break;
|  		case 4: printf("i = %d\n", i);
|  		case 5:	goto top;
|  		}
|  }

  Sorry for the big quote, but the code is hard enough to read complete,
and I doubt that anyone other than the author would follow the
discussion without seeing the source.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.lang.c mailing list