[try Beta version]
Not logged in

 
Suggestive Comments

Oct 13, 2009 at 4:41am
Are there are helpful pages or articles that will give me an example of using a program that reads a string that is an expression with two integers and an operator, and will find the answer. Such that if I had:

1024-810

The screen would output...
1024-810=214

Any suggestions are greatly appreciated.
Oct 13, 2009 at 4:48am
Google expression evaluation, but that'll probably be much more powerful and complicated than what you need. What operations do you need to implement other than subtraction?
Oct 13, 2009 at 4:51am
Ok. I only need subtraction for this program, I'm guessing cause this is the only form of arithmetic made in this program.
Oct 13, 2009 at 5:44am
How many terms? In other words, will it always be number minus number, or could it also be number minus ... minus number?
Oct 13, 2009 at 5:53am
Off-topic: I saw this topic title and thought of:

 
//insert your favorite innuendo phrase here 
Oct 13, 2009 at 6:19am
I think the answer always has to be positive, but when it comes to the size of the array(i think thats what your getting at) can be any size.

So Like
22000-100= ans
Oct 13, 2009 at 7:29am
Okay, so then all you need to do is split the string (std::string::substr()) at every minus sign (std::string::find()) and convert what's in between to integers (std::stringstream).
And you don't need an array. Just get the next term and subtract it from the final result.
Topic archived. No new replies allowed.