title: fgets() doesn't work as expected in C
body: <p>Given the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
   int testcase;
   char arr[30];
   int f,F,m;
   scanf("%d",&amp;testcase);
   while(testcase--)
   {
    printf("Enter the string\n"); 
    fgets(arr,20,stdin);
    printf("Enter a character\n");
    F=getchar();
    while((f=getchar())!=EOF &amp;&amp; f!='\n')
      ;
    putchar(F);
    printf("\n");
    printf("Enter a number\n");
    scanf("%d",&amp;m);
   }
   return 0;
  }
  </code></pre>
  
  <p>I want a user to enter a string, a character and a number until the testcase becomes zero.</p>
  
  <p>My doubts / questions:</p>
  
  <p>1.User is unable to enter a string. It seems <code>fgets</code> is not working. Why?</p>
  
  <p>2.If i use <code>scanf</code> instead of <code>fgets</code>,then <code>getchar</code> is not working properly, i.e whatever character I input in it just <code>putchar</code> as a new line. Why?</p>
  
  <p>Thanks for the help.</p>