title: Can't find where segmentation fault occurs
body: <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  #include &lt;dirent.h&gt;
  #include "header.h"
  
  char *ROOT = "/home/dereaper/Desktop/shared";
  
  void getFolders (char *PATH, int i) {
      const char *path = PATH;
      DIR *dir = opendir(path);
      struct dirent *entry;
      while(entry = readdir(dir)) {
          if(!strcmp(entry-&gt;d_name, ".") || !strcmp(entry-&gt;d_name, ".."))
              continue;
          printf("%s/%s INDEX:%d\n", path, entry-&gt;d_name, i);
          if(entry-&gt;d_type &amp; DT_DIR) {  //check file type
              char *new_path;
              strcat(new_path, path);
              strcat(new_path, "/");
              strcat(new_path, entry-&gt;d_name);
              getFolders(new_path, i+1); //segmentation fault when calling recursevly
  
              // otherwise the program returns the correct output
          }   
      }
      closedir(dir);
  }
  </code></pre>
  
  <p>Why am I getting segmentation fault?</p>