title: Recursive directory reading
body: <p>I'm trying to recursively get all files and sub folders of a directory. Here is what I have so far.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "dirent.h"
  #include &lt;io.h&gt;
  
  using namespace std;
  
  void listDir(char *directory)
  {
      DIR *dir;
      struct dirent *ent;
      if((dir = opendir (directory)) != NULL)
      {
          while ((ent = readdir (dir)) != NULL)
          {
              if(strstr(ent-&gt;d_name,".") != NULL)
                  cout&lt;&lt;ent-&gt;d_name&lt;&lt;endl;
              else
              {
                  strcat(directory,ent-&gt;d_name);
                  strcat(directory,"\\");
                  strcat(directory,"\0");
                  cout&lt;&lt;directory&lt;&lt;endl;
                  cin.get();
                  listDir(directory);
              }
          }
      }
      closedir (dir);
  }
  
  int main(int param, char **args)
  {
      char *path = new char[];
      path = args[1];
      strcat(path, "\\");
      listDir(path);
      cin.get();
      return 0;
  }
  </code></pre>
  
  <p>I am using dirent (actually pretty cool, get it if you don't already) and when I recursively get the folders it seems to add on to the directory at the end of my sub folder. For example:</p>
  
  <p><img src="https://i.stack.imgur.com/x2Irb.png" alt=""></p>
  
  <p>Downloads, Images, and Includes are all subfolders of my Jakes625 folder. Perhaps I'm missing something?</p>