title: How do I check if my program has data piped into it
body: <p>Im writing a program that should read input via stdin, so I have the following contruct.</p>
  
  <pre><code>FILE *fp=stdin;
  </code></pre>
  
  <p>But this just hangs if the user hasn't piped anything into the program, how can I check if the user is actually piping data into my program like</p>
  
  <pre><code>gunzip -c file.gz |./a.out #should work
  ./a.out  #should exit program with nice msg.
  </code></pre>
  
  <p>thanks</p>