Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

problem in execute of postfix to prefix

$
0
0
Sorry I dont speak English very well but I need to help me to execute this program about the conversation postfix to prefix expression. after the execute in turbo c ++ and enter the postfix expression ,the program don’t work and I don’t know where is problem in my program because don’t give me eror or warning . i want to find the problem of program to repair it
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include<string.h>
#define max 100
Void push(char);
Char pop();
Int *p;
Int *tos;
Int *bos;
Char i;
Void push(char)
{
If(p>bos)
{
Printf(“\n stack is full.”);
Return;
}
*p=i;
P++;
}
Char pop()
{
P--;
If(p<tos)
   {
   Printf(“\n stack is empty”);
Getch();
    Return 0;
    }
Return *p;
}
Int main()
Char s[80],b[80],x,y;
Int j;
P=(int*)malloc(max *sizeof(int));
If(!p)
{
Printf(“\n allocation failure”);
Exit(1);
}
Tos =p;
Bos=p+max-1;
Clrscr();
Printf(“\n enter postfix expression:”);
Gets(s);
For(j=0;j<80;j++)
{
     Do
       {
        If(s[j]==’+’ ||s[j]==’-‘||s[j]==’*’||s[j]==’/’||s[j]==’^’)
        {
               Y=pop();
                X=pop();
               Strcat(&x,&y);
               Strcat(&s[j],&x);
Push(s[j]);
}
Else
{
Push(s[j]);
}
B[80]=pop();
}
While(s[j]!=’\0’);
}
Printf(“\n the prefix expression is:”);
Puts(B)/>/>;
Getch();
Return 0;
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>