Hey guys, I need to write a code to evaluate postfix expression. I started on it but now I'm stuck. Below I have what I started on and the file that it needs to go into. I need it to do the following:
If the token is an operator of two items are popped off the stack. the operator is applied to them
the result is pushed back onto the stack


So far I have

for (i=0; i < token; i++)
if (token[i] == integer)
{
Push(token[i];
}
else if (token[i] == '*; || token[i] == '+'|| token[i] == '/' || token[i] == '-')
{
stack = pop();
stack2 = pop();

switch(token[i])
{
case '+' : q= stack2 + stack break;
case '-' : q= stack2 - stack break;
case '*' : q= stack2 * stack break;
case '/' : q= stack2 / stack break;
}

Push (q);

z = Pop();
return z

First things first -- format your code so we can follow what you are doing.

The concepts looks good except for the ';' on line 6.

I'd also change the names of stack and stack2 to value1 and value2

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.