Hello friends. I'm new here and would like help in this code that converts infix expression to postfix. The code is converting correctly, but I would like to get the result of the operation. Can anyone help me with a hint on converting the "stringstream output" Or the "output.str ()" in an "int result", with the result of the operation?
the first thing you need is a separator in your output stream. A whitespace would suffice. Add it whenever a non numeric value appears. It actually doesn't matter if you have more than one whitespace.
The second thing is that you need a second stack for the numbers. Place each number on the stack until an operator is reached then pop the last number and apply the operation to the top number.
The operator can be determined when the stream raises an error on reading a numeric value. When this error arise you need to use ignore. See: