Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: strings as functions Message-ID: <1991Jan7.165639.10403@zoo.toronto.edu> Organization: U of Toronto Zoology References: Date: Mon, 7 Jan 1991 16:56:39 GMT In article mpapp@ (Mike Papper) writes: >Is there a way to use a string value as the name of a function? >In other words, can I use a string (possibly >typed in by a programmer) as a function call to a function of >the same name? Not in standard C. There has to be a table, somewhere, that maps names into pointers to functions. In a conventional implementation, that table exists inside compiler and linker during compilation of the program, but no longer exists at run time. (It is sometimes present in the same file that holds the executable program, but there is no fully portable way of getting at that file or interpreting its contents.) The only way to implement such a feature portably is to decide in advance which functions can be called this way, and provide your own table. -- If the Space Shuttle was the answer, | Henry Spencer at U of Toronto Zoology what was the question? | henry@zoo.toronto.edu utzoo!henry