Thread: Convert a string to a statement?

  1. #1
    Registered User
    Join Date
    Nov 2008
    Little Rock, AR

    Convert a string to a statement?

    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?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    No, but you can map strings to function pointers.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Pointers to functions article below may help

  4. #4
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    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.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  3. Convert C++ string to int
    By markucd in forum C++ Programming
    Replies: 11
    Last Post: 01-19-2006, 07:49 AM
  4. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  5. convert double to string problem
    By gandalf_bar in forum C++ Programming
    Replies: 6
    Last Post: 03-15-2004, 05:14 AM