title: How do I flush the i/o stream? I'm using scanf(), fflush(stdin) doesnt work
body: <p>How can I flush the input buffer without putting a newline character in scanf()? Because my proffessor doesn't like it. I tried fflush(); but it didn't work.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  int CountUpper(char S[],int n)
  {
      int i,cntr = 0;
      for(i = 0; i &lt; n; i++)
          if(S[i] &gt;= 'A' &amp;&amp; S[i] &lt;= 'Z')
              ++cntr;
      return cntr;
  }
  int main(void)
  {
      int n,i;
      printf("Enter n: ");
      scanf("%d",&amp;n);
      char array[n];
      for(i = 0; i &lt; n; i++)
      {
          scanf("%c",&amp;array[i]);
          //fflush(stdin);
      }
      printf("Number of uppercase characters in array: %d\n",CountUpper(array,n));
      getch();
      return 0;
  }
  </code></pre>