This is my first question so pardon for non technical language
I am making a program to convert infix to prefix and postfix. I made infix to postfix which is working. Now when I want to infix to prefix we need to reverse the expression. So I thought to read infix from reverse direction.
while(*e != '\0')
{
if(isalpha(*e))
printf("%c ",*e);
else if(*e == '(')
push(*e);
else if(*e == ')')
{
while((x = pop()) != '(')
printf("%c ", x);
}
else
{
while(priority(stack[top]) >= priority(*e))
printf("%c ",pop());
push(*e);
}
e++;
}
Above is part of infix to postfix in which e
is pointer which scans through string. In infix to pre I plan to replace e++ to e--
But as in first lines we see it prints the char directly so I need to reverse direction
Eg.
a
ba
+ba
You thought I will process and reverse it, no you are wrong. I will read it in reverse direction and then process it so I would get `bc*a+` so I need to print it in reverse direction. That is what I asked – Parnaval Mar 08 '21 at 05:02