Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!mcvax!unido!tub!net From: net@tub.UUCP (Oliver Laumann) Newsgroups: comp.lang.c Subject: Re: Functions pointers and stuff Keywords: Dynamic, pointers to functions Message-ID: <803@tub.UUCP> Date: 28 Mar 89 10:03:08 GMT References: <1715@leah.Albany.Edu> Reply-To: net@tub.UUCP (Oliver Laumann) Organization: Technical University of Berlin, Germany Lines: 22 In article <1715@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes: > 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. You can look up the name in the program's symbol table, cast the value of the symbol to "pointer to function returning ...", and call it. Of course, this requires that your program can determine it's file name, that the file is readable, that it has a symbol table, that the function has not been declared as "static", etc., but you get the idea. -- Oliver Laumann, Technical University of Berlin, Germany. ...!pyramid!tub!net or net@TUB.BITNET ...!mcvax!unido!tub!net