fork download
  1. #include <stdio.h>
  2. char stack[20];
  3. char stack2[20];
  4. char stack3[20];
  5. int top=-1;
  6. int top2=-1;
  7. int top3=-1;
  8. int main()
  9. {
  10. char exp[20];
  11. char *e,*x,y;
  12. printf("expression is :");
  13. scanf("%s",exp);
  14. e=exp;
  15. while(*e!='\0')
  16. {push(*e);
  17. e++;}
  18. while(top!=-1)
  19. {x=pop();
  20. if(isalnum(x))
  21. push2(x);
  22. else if(x==')')
  23. push3(x);
  24. else if(x=='(')
  25. {
  26. while ((y=pop3())!=')')
  27. push2(x);
  28. }
  29. else
  30. {
  31. while(priority(stack3[top3])>=priority(x))
  32. push2(pop3());
  33. push3(x);
  34. }
  35. while(top3!=-1)
  36. {push2(pop3());}
  37. while(top2!=-1)
  38. printf("%c",pop2());
  39. }
  40. }
  41. void push(char x)
  42. {
  43. stack[++top]=x;
  44. }
  45. void push2(char x)
  46. {
  47. stack2[++top2]=x;
  48. }
  49. void push3(char x)
  50. {
  51. stack3[++top3]=x;
  52. }
  53. char pop()
  54. {
  55. if (top==-1)
  56. return -1;
  57. else
  58. return stack[top--];
  59. }
  60. char pop2()
  61. {
  62. if (top2==-1)
  63. return -1;
  64. else
  65. return stack2[top--];
  66. }
  67. char pop3()
  68. {
  69. if (top3==-1)
  70. return -1,
  71. else
  72. return stack3[top3--];
  73. }
  74.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:16:4: warning: implicit declaration of function ‘push’ [-Wimplicit-function-declaration]
   {push(*e);
    ^~~~
prog.c:19:6: warning: implicit declaration of function ‘pop’ [-Wimplicit-function-declaration]
   {x=pop();
      ^~~
prog.c:19:5: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   {x=pop();
     ^
prog.c:20:6: warning: implicit declaration of function ‘isalnum’ [-Wimplicit-function-declaration]
   if(isalnum(x))
      ^~~~~~~
prog.c:21:4: warning: implicit declaration of function ‘push2’ [-Wimplicit-function-declaration]
    push2(x);
    ^~~~~
prog.c:22:12: warning: comparison between pointer and integer
   else if(x==')')
            ^~
prog.c:23:4: warning: implicit declaration of function ‘push3’ [-Wimplicit-function-declaration]
    push3(x);
    ^~~~~
prog.c:24:12: warning: comparison between pointer and integer
   else if(x=='(')
            ^~
prog.c:26:14: warning: implicit declaration of function ‘pop3’ [-Wimplicit-function-declaration]
    while ((y=pop3())!=')')
              ^~~~
prog.c:31:11: warning: implicit declaration of function ‘priority’ [-Wimplicit-function-declaration]
     while(priority(stack3[top3])>=priority(x))
           ^~~~~~~~
prog.c:31:5: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation]
     while(priority(stack3[top3])>=priority(x))
     ^~~~~
prog.c:33:5: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘while’
     push3(x);
     ^~~~~
prog.c:38:17: warning: implicit declaration of function ‘pop2’ [-Wimplicit-function-declaration]
     printf("%c",pop2());
                 ^~~~
prog.c: At top level:
prog.c:41:6: warning: conflicting types for ‘push’
 void push(char x)
      ^~~~
prog.c:16:4: note: previous implicit declaration of ‘push’ was here
   {push(*e);
    ^~~~
prog.c:45:6: warning: conflicting types for ‘push2’
 void push2(char x)
      ^~~~~
prog.c:21:4: note: previous implicit declaration of ‘push2’ was here
    push2(x);
    ^~~~~
prog.c:49:6: warning: conflicting types for ‘push3’
 void push3(char x)
      ^~~~~
prog.c:23:4: note: previous implicit declaration of ‘push3’ was here
    push3(x);
    ^~~~~
prog.c:53:6: error: conflicting types for ‘pop’
 char pop()
      ^~~
prog.c:19:6: note: previous implicit declaration of ‘pop’ was here
   {x=pop();
      ^~~
prog.c:60:6: error: conflicting types for ‘pop2’
 char pop2()
      ^~~~
prog.c:38:17: note: previous implicit declaration of ‘pop2’ was here
     printf("%c",pop2());
                 ^~~~
prog.c:67:6: error: conflicting types for ‘pop3’
 char pop3()
      ^~~~
prog.c:26:14: note: previous implicit declaration of ‘pop3’ was here
    while ((y=pop3())!=')')
              ^~~~
prog.c: In function ‘pop3’:
prog.c:71:2: error: expected expression before ‘else’
  else
  ^~~~
prog.c:70:12: warning: left-hand operand of comma expression has no effect [-Wunused-value]
   return -1,
            ^
prog.c:73:2: warning: control reaches end of non-void function [-Wreturn-type]
  }
  ^
stdout
Standard output is empty