title: How to ignore hidden files with opendir and readdir in C library
body: <p>Here is some simple code:</p>
  
  <pre><code>DIR* pd = opendir(xxxx);
  struct dirent *cur;
  while (cur = readdir(pd)) puts(cur-&gt;d_name);
  </code></pre>
  
  <p>What I get is kind of messy: including dot (<code>.</code>), dot-dot (<code>..</code>) and file names that end with <code>~</code>.</p>
  
  <p>I want to do exactly the same thing as the command <code>ls</code>. How do I fix this, please?</p>