title: Can fseek(stdin,1,SEEK_SET) or rewind(stdin) be used to flush the input buffer instead of non-portable fflush(stdin)?
body: <p>Since I discovered <code>fflush(stdin)</code> is not a portable way to deal with the familiar problem of <em>"newline lurking in the input buffer"</em>,I have been using the following when I <strong>have to</strong> use <code>scanf</code>:</p>
  
  <pre><code>while((c = getchar()) != '\n' &amp;&amp; c != EOF);
  </code></pre>
  
  <p>But today I stumbled across this line which I had noted from <A href="http://www.cplusplus.com/reference/cstdio/fflush/?kw=fflush" rel="noreferrer">cplusplus.com on fflush</a>:</p>
  
  <blockquote>
    <p>fflush()...in files open for update (i.e., open for both reading and writting), the stream shall be flushed after an output operation before performing an input operation. This can be done either by repositioning (fseek, fsetpos, rewind) or by calling explicitly fflush</p>
  </blockquote>
  
  <p>In fact, I have read that before many times.So I want to confirm if I can simply use anyone of the following before the <code>scanf()</code> to serve the same purpose that <code>fflush(stdin)</code> serves when it is supported:</p>
  
  <pre><code>fseek(stdin,1,SEEK_SET);
  rewind(stdin);
  </code></pre>
  
  <p><strong>PS</strong> <code>rewind(stdin)</code> seems pretty safe and workable to flush the buffer, am I wrong?</p>
  
  <p><strong>Mistake</strong> I should have mentioned <code>fseek(stdin,0,SEEK_SET)</code> if we are talking about <code>stdin</code> as we can't use any offset other than 0 or one returned by <code>ftell()</code> in that case.</p>