Thursday, Jan 17th

Last update12:59:40 PM GMT

If I have the name of a function in the form of a string, how can I invoke that function?

Write e-mail

Keep a table of names and their function pointers:

int myfunc1(), myfunc2();

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

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

Share this post

Web Hosting