Hi,

Compilers usually convert expressions to postfix notation. If i have an expression 1 + 2, then the postfix notation version would be 1 2 +, and if i have 7 / 4, i will get 7 4 /. I have to write a program to convert infix notation to postfix notation. However i can't get it to work. Pls help me check if there are any logical errors and such. If you want to read the algorithm first, it's below, thnx.

The algorithm is to have two arrays and a stack. The program should read the expression into char array infix, then create the postfix expression in char array postfix.

1. First push a left parenthesis onto the stack.

2. Then append a right parenthesis to the end if infix.

3. While stack is not empty, read infix from left to right and do

the following:

If current character in infix is a digit, copy it to the next element of postfix.

If current char in infix is left parenthesis, pus it onto the stack.

If current char in infix is an operator, pop operators ( if any) at top of stack while they have equal or higher precedence than current operator, then insert the popped operators in postfix.

Push current character in infix onto stack.

If current character in infix is a right parenthesis, pop operators form the top of stack and insert them in postfix until a left parenthesis is at top of stack. Then pop and discard the left parenthesis from the stack.

thnx in advance