InFix to PostFix function Operator don't show

//Here is the code when I run it operands are displayed but all operators are garbage data. Can you please help me figure it out. 

if (isOperator(expression[i]) == 0)
          {
                  while (((isEmpty() != -1) && (priority(expression[i]) <= priority(stack[getTop()]))))
                  {
                    exp[j++] = expression[i];
                  }
                  push(expression[i]);
          }

the while checks if the stack is empty and that the priority of the operator is less or equal than the one of the pre-existing operator. IsOperator checks if the scanned character is an operator and returns 0 or 1 i is a counter of the for loop that traverses the whole string. And is also the index of the input expression. j is the index of the output expression

for instance when i enter: a+b-cd expected output: ab+cd- Real output: abcd?

Upvotes: 0

Views: 41

Answers (0)

Related Questions