Arcane C hacks?

a.reed hfavr at mtuxo.UUCP
Wed Feb 19 11:33:21 AEST 1986


Robert Herndon writes:
>   I wrote a mild flame in another newsgroup about this, but
> somebody out there might know another way.
>   The problem is this:  I'd like to construct a jump table by
> putting lots of labels into an array, and then issuing a
> statement like
> 		goto jumptab[i];

Such a table is automatically built by the compiler when you do
	switch (i) {	case 1: goto label_a;
			case 2: goto label_b;	} /* etc. */
This can do everything you need, and gives you the benefit of
readable labels.
			Adam Reed (ihnp4!npois!adam)



More information about the Comp.lang.c mailing list