title: how can I get this readdir code sample to search other directories
body: <p>I am currently working with a code example that initially is designed to take an argument, then search for that argument in the current directory, I've tried to make it search another directory (/dev/shm to exact) by replacing the "." with "/dev/shm" but the code turns up nothing when i search for something* (notice the wildcard). The wild card search works fine in the current directory so I do not think it is the wild card that is the problem, If someone could help me out though I would really appreciate it, thanks!</p>
  
  <pre><code>#include &lt;dirent.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  
  static void lookup(const char *arg)
  {
      DIR *dirp;
      struct dirent *dp;
  
  
      if ((dirp = opendir(".")) == NULL) {
          perror("couldn't open '.'");
          return;
      }
  
  
      do {
          errno = 0;
          if ((dp = readdir(dirp)) != NULL) {
              if (strcmp(dp-&gt;d_name, arg) != 0)
                  continue;
  
  
              (void) printf("found %s\n", arg);
              (void) closedir(dirp);
                  return;
  
  
          }
      } while (dp != NULL);
  
  
      if (errno != 0)
          perror("error reading directory");
      else
          (void) printf("failed to find %s\n", arg);
      (void) closedir(dirp);
      return;
  }
  
  
  int main(int argc, char *argv[])
  {
      int i;
      for (i = 1; i &lt; argc; i++)
          lookup(argv[i]);
      return (0);
  }
  </code></pre>