Seven Original Sins of K&R (Long)
Doug McDonald
mcdonald at aries.scs.uiuc.edu
Wed Sep 26 23:47:16 AEST 1990
In article <4700066 at m.cs.uiuc.edu> gillies at m.cs.uiuc.edu writes:
>
>Re: Sin #IV
>
>Hey, how else can I write the following amazingly convoluted code
>(idea courtest of Harbison & Steele's book, first edition):
>
>main()
>{
>int x,i;
>x=1;
>switch(x) {
> case 1:
> for (i=0; i < 10; i++)
> case 2:
> printf("%d ",i);
>}
>}
>
>And the result:
>
>0 1 2 3 4 5 6 7 8 9
Well, in a C-like language WHERE THE CASES DIDN'T FALL THROUGH
you could write:
>main()
>{
>int x,i;
>x=1;
>switch(x) {
> case 1:
> for (i=0; i < 10; i++)
goto 2;
> case 2:
> printf("%d ",i);
>}
>}
Doug McDonald
More information about the Comp.lang.c
mailing list