[Solved] Postfix notation stack C++ [closed]

[ad_1]

  • Using stack.top() is illegal if the stack is empty.
    Change while((!highPrecedence(stack.top(),c)) && (stack.size()!=0)){
    to while((!stack.empty()) && (!highPrecedence(stack.top(),c))){
  • The initiali value of i is not good and you are printing uninitialized variable, which has indeterminate value.
    Change int i=0; to int i=-1;

1

[ad_2]

solved Postfix notation stack C++ [closed]