Is there a way to convert a string to a function call or other valid C statement? Say I have a string char *some_func_call. Can I use what is in that string to create a valid C statement and execute it?
Is there a way to convert a string to a function call or other valid C statement? Say I have a string char *some_func_call. Can I use what is in that string to create a valid C statement and execute it?
No, but you can map strings to function pointers.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Pointers to functions article below may help
http://www.cplusplus.com/doc/tutorial/pointers.html
What you are asking to do is typically what can easily be done in an interpreted language, like a Perl or Ruby script. In a compiled language, it is difficult to do unless you've specifically planned for it ahead of time.
Mainframe assembler programmer by trade. C coder when I can.