title: Why fflush(stdin) does not remove buffer (stdin)
body: <p>I have a test code like this</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
      char c, str[20];
      printf("Enter a character : ");
      scanf("%c", &amp;c);
      printf("Enter a string : ");
      fflush(stdin);
      gets(str);
      printf("\n\n\nResult : %c\n%s\n", c, str);
      return 0;
  }
  </code></pre>
  
  <p>I've read some articles said that this code will work because after scanning the c character, there is still '\n' character in the buffer. The fflush(stdin) will clear the buffer, so gets() function can work properly</p>
  
  <p>But in fact, when I compile and run this code in Mac OS environment, fflush(stdin) do nothing. I entered a character (for ex, 'k'), then it print the k character and a '\n' character. It supposes to allow me to enter a character, a string and then print both of them. Anyone know why?
  Thanks!</p>