- Using
stack.top()
is illegal if thestack
is empty.
Changewhile((!highPrecedence(stack.top(),c)) && (stack.size()!=0)){
towhile((!stack.empty()) && (!highPrecedence(stack.top(),c))){
- The initiali value of
i
is not good and you are printing uninitialized variable, which has indeterminate value.
Changeint i=0;
toint i=-1;
1
solved Postfix notation stack C++ [closed]