title: Is it a bad idea to clear the buffer using a macro in C?
body: <p>i was using a macro i created to clear the buffer after a scanf, but i was told it is not a good idea for "Many reasons". Could you explain me why and how should i clean it? I know that using fflush(stdin) is a very bad idea since it's not defined.</p>
  
  <p>This is the macro i was using:</p>
  
  <pre><code>#define CLEAR_BUFFER do { c = getchar(); } while (c != '\n' &amp;&amp; c != EOF);
  </code></pre>
  
  <p>And also, another question: in the "real world" is scanf used? And if yes, how do people clean the buffer?</p>
  
  <p>Thanks</p>