title: Not able to read input from stdin/STDIN_FILENO in C?
body: <p>I have this command line argument -</p>
  
  <pre><code>cat file_name | ./a.out 
  </code></pre>
  
  <p>The problem is not reading from the cat command inside the C program as we can do that with <code>read()</code>, <code>fgets()</code>, <code>fgetc()</code> but the actual problem I am facing is after reading the data from <code>cat</code> I am not able to take input from user using <code>fgets</code>.</p>
  
  <p>Here is my sample code</p>
  
  <pre><code>while(fgets(buffer, BUFSIZ, stdin ) != NULL )
      puts( buffer ); // Here I have tried strtok( buffer, "\n" ) too.
  memset( buffer, 0, BUFSIZ );`
  </code></pre>
  
  <p>The problem is after this line, it is not asking for the input like the below is not working-</p>
  
  <pre><code>puts("Name: ");
  fgets( buffer, BUFSIZ, stdin );
  </code></pre>
  
  <p>Help me with what's wrong happening here?</p>