Functions pointers and stuff
Robert Seals
rds95 at leah.Albany.Edu
Tue Mar 28 04:11:16 AEST 1989
I got a question. Suppose I know the name of a function, like so:
char *f = "A_Function";
and I got a function of the same name like so:
void A_Function(void) { /* stuff */ }
Is there some sneaky way to execute the function when all I know is
the name of it, i.e., a pointer to several letters which spell it's name.
What I do now is have a table of names and pointers to functions, and
I have a function returning pointer to function, that, given a character
pointer, looks up the name in the table, and returns the corresponding
pointer, which I then execute. It works fine, but I just wondered if
there was something else...and if I'm just being dumb, well, I'm sure
you'll clue me in.
rob
More information about the Comp.lang.c
mailing list