www.thecareerplus.com
The CareerPlus
Home Technical Resources Programming Functions
Wednesday 08th September 2010
 
 
If I have the name of a function in the form of a string, how can I invoke that function?

Discuss it!          



Keep a table of names and their function pointers:


int myfunc1(), myfunc2();

struct 
{ 
  char *name; 
  int (*func_ptr)(); 
} func_table[] = {"myfunc1", myfunc1,
                  "myfunc2", myfunc2,};


Search the table for the name, and call via the associated function pointer.


Discuss it!          

CrackTheIntervew.NET
Advertisement
 
Top! Top!