/* solution of convertion of infix to postfix */ #include <stdio.h> #include <stdlib.h> #include <string.h> struct StackRecord { char Operator[32]; int TopIndex; int Capacity; }; typedef struct StackRecord * Stack; Stack CreateStack() { Stack S = malloc(sizeof(struct StackRecord)); S->TopIndex = -1; S->Capacity = 32; } inline int IsEmpty(Stack S){return S->TopIndex == -1;} inline int IsFull(Stack S){return S->TopIndex == 31;} void Push(Stack S,char Operator) { // assuming S is not NULL, hha S->Operator[++S->TopIndex] = Operator; } char Pop(Stack S) { if(IsEmpty(S)) return 0; return S->Operator[S->TopIndex--]; } char Top(Stack S) { if(IsEmpty(S)) return 0; return S->Operator[S->TopIndex]; } int GetOperatorClass(char Operator) { switch(Operator) { case '+': case '-': return 0; case '*': case '/': return 1; case '^': return 2; case '(': return 10; default: return -1; } } int IsOperator(char c) { switch(c) { case '+':case '-':case '*':case '/':case '(':case ')':case '^': return 1; default: return 0; } } void PrintStack(Stack S) { int i = 0; printf("Current Stack: "); for(; i <= S->TopIndex; ++i) printf("%c ", S->Operator[i]); printf(" "); } int main() { char *infix = "a+b*c^h^i+(d*e+f)*g"; char postfix[128] = "