[net.unix-wizards] declaring and initializing an array of pointers to functions

Uc.Gds%mit-eecs@BRL-VGR.ARPA (02/15/84)

From:  Greg Skinner <Uc.Gds%mit-eecs@BRL-VGR.ARPA>

I'd like to know how to do this.  I have an array of keywords that I
am parsing and would like if a certain keyword is parsed successfully
a function at the same index as the keyword was at is called.
Unfortunately, I do not know how to set up an array of pointers to
functions and I wasn't able to find out from the C manual.
-------

gwyn%brl-vld@sri-unix.UUCP (02/28/84)

From:      Doug Gwyn (VLD/VMB) <gwyn@brl-vld>

typedef	int	valtype;		/* function return value type */

extern valtype	funca(), funcb(), ... funcz();	/* the functions */

static valtype	(*table[])() =		/* pointers to functions */
	{ funca, funcb, ... funcz };

...

	/* keyword # k has been recognized; call function */
	value = (*table[k])( args );

...