Can someone pls help me?
I cant get my program to work
Here's the code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern void InitializeStack (stack *S);
extern int FullStack (stack *S);
extern int EmptyStack (stack *S);
extern void Pop (stack *S,int *X);
extern void Push (stack *S, int X);
void main(){
stack s;
char str[100],PFstring[100],a;
int i=0;
PFstring[0]='\0';
printf("Enter infix expression with parantheses: ");
scanf("%s", str);
InitializeStack(&s);
while(str[i]!='\0'){
if(str[i]>='0'&&str[i]<='9')
strncat(PFstring,&str[i],1);
else if(str[i]='(')
Push(&s,str[i]);
else if(str[i]=')'){
Pop(&s,&a);
while(a!='('){
strncat(PFstring,&a,1);
Pop(&s,&a);
}
}
else if(!EmptyStack(&s)){
Pop(&s,&a);
switch(str[i]){
case'-':
case'+':if(a=='(')
Push(&s,a);
else
strncat(PFstring,&a,1);
break;
case'*':
case'/':if(a=='+'||a=='-'||a=='(')
Push(&s,a);
else
strncat(PFstring,&a,1);
break;
case'^':if(a=='^')
strncat(PFstring,&a,1);
else
Push(&s,a);
break;
}
Push(&s,str[1]);
}
i++;
}
while(!EmptyStack(&s)){
Pop(&s,&a);
strncat(PFstring,&a,1);
}
printf("The postfix expression is %s\n", PFstring);
}
Its only a portion of the program.I didnt include the function declaration but the prototype.The error i keep on getting is cannot convert from int* to char*.How do I change the code without changing the structure of my stack functions?I can affort to change the stack functions cause it will cause problem in my other functions.



LinkBack URL
About LinkBacks



