title: misunderstanding the working mechanism of getint function
body: <p>In K&amp;R, at the beginning of chapter 5, is presented the function getint that </p>
  
  <blockquote>
    <p>performs free-format input conversion by breaking a stream of charachters into integer values, one integer per call.</p>
  </blockquote>
  
  <p>The function is pretty simple, but i can't actually understand why is <code>c</code> pushed back in to the buffer in the first <code>if-statement</code>. Because of this, every time you call <code>getint</code> it will do the same thing. Because it will read the next charachter in the <code>buffer</code>, which is <code>c</code>.
    Is this strategy intended to be a kind of security mechanism?</p>
  
  <pre><code>int getint(int *pn) {
      int c, sign;
      while(isspace(c = getch()))
          ;
      if(!isdigit(c) &amp;&amp; c != EOF &amp;&amp; c != '+' &amp;&amp; c != '-') {
          ungetch(c);
          return 0;
      }
  
      sign = (c == '-') ? -1 : 1;
      if(c == '+' || c == '-')
          c = getch();
  
      for(*pn = 0; isdigit(c); (c = getch()))
          *pn = 10 * *pn + (c - '0');
      *pn *= sign;
      if(c != EOF)
          ungetch(c);
      return c;
  
  }
  </code></pre>