mildly obfuscating c
Steve Pozgaj
steve at hcradm.UUCP
Tue Dec 10 11:11:41 AEST 1985
In article <564 at puff.UUCP> tom at puff.UUCP writes:
>i haven't been able to figure out anyway to "goto" a label that
>i don't know. for example, i would like to do this:
>
>-------------------------------------------------------------
>main() {
> int (*jump[])() = { l1,l2,l3,l4,l5,l6,l7,l8 }
>
> l1: /* code */
> l2: /* code */
> l3: /* code */
> l4: /* code */
> l5: /* code */
> l6: /* code */
> l7: /* code */
> l8: /* code */
>
> goto *jump[whatever]
>}
>-------------------------------------------------------------
>
>aside from the forward-referencing problem of the unseen labels,
>this is a still syntax error. anyone have any way to do this?
Yes, it's called a "switch" statement, and was designed to obviate the need for
people translating Fortran to C and attempting to kludge out a computed goto.
A little careful rethought can usually recast computed goto's in a switch.
More information about the Comp.lang.c
mailing list