- Using
stack.top()is illegal if thestackis empty.
Changewhile((!highPrecedence(stack.top(),c)) && (stack.size()!=0)){
towhile((!stack.empty()) && (!highPrecedence(stack.top(),c))){ - The initiali value of
iis 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]