title: not getting expected output from fgets() function
body: <p>Here simple code I am not getting the expected output.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
     char buf[1024];
     while(1)
     {
        fgets(buf,strlen(buf),stdin);
        printf("%s",buf);
        printf("hello");
     }
  }
  </code></pre>
  
  <p>In the above code I am want whatever the string I enter from keyboard to be printed out to me the same and then hello.
  As I know fgets() is a blocking function till I input a string from keyboard and press ENTER it will block the program till that time. So when I run it I expect it as follows</p>
  
  <pre><code>$ ./a.out
  I input some text here &lt;ENTER&gt;
  I input some text here 
  hello
  </code></pre>
  
  <p>But actually what I am getting output is infinite loop of "hello" printed on terminal. Why my fgets() not blocking the program? Any idea?</p>