Infix to postfix expression conversion

Link have code and bad out put pic. ( and ) seem mess things up and not sure how else to handle. Any help appreciated.
I don't understand why you take a picture of the code instead of posting it with [code] [/code] tags, but anyway..

Are you using std::stack or your own custom stack? std::stack::top() is a function. You need to use parenthesis to call it. But other than that, my suggestion is to start small. Start with test cases for simple expressions before you move onto such a complex expression. e.g. do just "(a + b)" and then go through your code line by line, to see where your code's behavior starts to diverge from what you expect it to do. If "(a + b)" works, then do something just a tad more complicated, like "c * ( a + b)". A debugger with step-in operations is a great tool for this sort of thing.

And if you paste your code, you should paste code that can compile without any changes needed -- a minimal program that can compile so someone on the forum can simply copy your code and try to run it, without tediously adding things to it. This means showing any class declarations, #includes, functions you use, and a main() function.
Last edited on
Registered users can post here. Sign in or register to post.