title: How to distinguish a file pointer points to a file or a directory?
body: <p>When I do:  </p>
  
  <pre><code>FILE * fp = fopen("filename", "r");`  
  </code></pre>
  
  <p>How can I know the file pointer fp points to a file or a directory? Because I think both cases the fp won't be null. What can I do?  </p>
  
  <p>The environment is UNIX.</p>