title: printing directories code on UNIX makes error
body: <p>I've been studying UNIX and there's a example code on the book,</p>
  
  <p>but this code seems not working. When I compile the code, returns segmentation error.</p>
  
  <pre><code>#include&lt;dirent.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;unistd.h&gt;
  #include&lt;sys/types.h&gt;
  
  int my_double_ls(const char *name)
  {
     struct dirent *d;
     DIR *dp;
  
     if ((dp=opendir(name)) == NULL)
      return (-1);
  
     while (d=readdir(dp)) {
      if (d-&gt;d_ino != 0)
          printf("%s\n", d-&gt;d_name);
     }
  
     rewinddir(dp);
  
    while (d = readdir(dp)) {
      if (d-&gt;d_ino != 0)
          printf("%s\n", d-&gt;d_name);
    }
  
    closedir(dp);
    return(0);
  }
  
  int main(int argc, char **argv){
  
    my_double_ls(argv[1]);
  
    return(0);
  }
  </code></pre>