title: C Language: How to know when there is no more input from stdin when redirecting input from a file
body: <p>My program is supposed to run in the following way:</p>
  
  <p>CProgram &lt; file.txt</p>
  
  <p>file.txt can has as many rows of data as it wants. For instance,</p>
  
  <pre><code>2 3 G 5 6
  5 6 7 
  6 9 3 6 H
  &lt;&lt;Blank line&gt;&gt;
  </code></pre>
  
  <p>Is there a way to know that that there is no more input rows? Every file has a blank line at the end. </p>
  
  <p>I am able to read the rows but my program never comes to know if there is no more data to be read and keeps waiting for more data as it would normally expect from stdin.</p>
  
  <p>This is how I am reading it</p>
  
  <pre><code> while( fgets(line, sizeof(line), stdin) != NULL) {
     ... do something
  }
  </code></pre>