int getweight(char symbol )
{
switch(symbol)
{
case '(':
return 0;
case '+':
case '-':
return 1;
case '*':
case '/':
case '%':
return 2;
case '^':
return 3;
}
}
int pop()
{
if (top==-1)
{
printf("Stack underflow \n");
return -1;
}else
return (stack[top--]);
}
void infix2postfix()
{
int i,type,weight;
int p=0;
char next ;
stack[top]='#';
int len=strlen(infix);
for(i=0;i<len;i++)
{
switch(infix[i])
{
case '(':
push(infix[i]);
break;
case '+':
case '-':
case '*':
case '/':
case '%':
case '^':
weight = getweight(infix[i]);
while(stack[top]!='#' &&
weight<= getweight(stack[top]))
postfix[p++] = pop();
push(infix[i]);
break;