title: how to scanf a number-and-operator series using a while loop?
body: <p>I have a stdin input like " 33 44 55 + 66 * + = ", (i.e, Reverse Polish notation，RPN), and I use codes as follows to parse it. But scanf("%d") reads '+' and discards it, how to ungetc the operator and make it be read by scanf(" %c ")? What is the best way to solve the problem. Thanks.</p>
  
  <pre><code>while ((reta = scanf("%d", &amp;operand)) == 1 || (retb = scanf(" %c ", &amp;operator)) == 1) {
    if (reta == 1) push(exprStack, operand);
    else if (retb == 1) {
      operand = pop(exprStack);
      /* function pmtd executes some basic calculation, i.e., plus, minus, times and divide */
      push(exprStack, pmtd(operator, pop(exprStack), operand));
    }
  } 
  </code></pre>