title: How to evaluate postfix when there is no whitespace?
body: <p>My program evaluates postfix expressions well when there are white spaces, but a simple one like '56*' with no white space cannot be evaluated. How do I do that?</p>
  
  <p>Also, "1.2e3 -3.4e-1 /" it cannot understand the (-1) of e notation and takes it as +1. This is another problem. I need to adjust the code to adapt to it.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;math.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define SIZE 50 /* Size of Stack */
  
  double s[SIZE];
  int peak=-1; /* Global declarations */
  char pofx[50];
  
  double pop()
  {                      /* Function for POP operation */
    return(s[peak--]);
  }
  
  double push(double elem) {
    if (peak + 1 &gt;= SIZE) {
      printf("Stack overflow\n");
      return 0;
    }
    s[++peak] = elem;
  }
  
  void main()
  {                         /* Main Program */
      printf("Enter the Postfix Expression:");
      // fgets(pofx,100,stdin); // 100??
      fgets(pofx, sizeof pofx, stdin); // better
      postfixtoresult();
      printf("Result: %lf\n",s[peak]);
  }
  
  void postfixtoresult()
  {            
    int i=0;
    const char *st = pofx;
  
    while (*st) {
      char *end; //location to store end of FP parsing
      double value = strtod(st, &amp;end);
      if (end &gt; st) {
        push(value);
        st = end; 
      } else if (isspace((unsigned char) *st)) {
        st++;
      } else {
        switch (*st) {
          case '+':push(pop() + pop());break; // pop order irrelevant
          case '-':{ double t = pop(); push(pop() - t);break; } // pop order             relevant
          case '*':push(pop() * pop());break; // pop order irrelevant
          case '/':{ double u = pop(); push(pop() / u);break; }  // pop order relevant
          case '^':{ double v = pop(); push(pow(pop(),v));break; }  // pop order relevant
  
          default: {
            printf("Input invalid operator: character code %d\n", *st);
            return 0;
          } 
        }  // end switch
        st++;
      }
    }     
  }   
  </code></pre>