Thread: evaluating strings

  1. #1
    steve8820
    Guest

    Question evaluating strings

    I am trying to evaluate a string entered by the user. I want to do something similar to the eval function in Matlab. For example, if the user enters :

    p OR NOT q

    I would then prompt them for the values of p and q. The user would enter either a 1 or 0 for each, then I would display if the expression is either true or false. I already know how to use the or, and, and not operators in C. My problem is if I trace through the input string and make a new string which would be:

    p | ! q

    How do I evaluate this expression if it is still a string?

    Thanks

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    28
    I guess you will have to write code to parse the string yourself and calculate the result via code only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. evaluating strings
    By tdean in forum C Programming
    Replies: 3
    Last Post: 02-03-2003, 01:37 PM
  5. Evaluating strings
    By whitel1977 in forum C Programming
    Replies: 10
    Last Post: 11-23-2002, 07:21 PM