Suggestive Comments

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.
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?
Ok. I only need subtraction for this program, I'm guessing cause this is the only form of arithmetic made in this program.
How many terms? In other words, will it always be number minus number, or could it also be number minus ... minus number?
Off-topic: I saw this topic title and thought of:

 
//insert your favorite innuendo phrase here 
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
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.