title: c++ read content of a pointer
body: <p>i'm new in c++ world, i just use it for litle app that help me in my work, now, i need to read the content of a folder, list the folder content, i've made a function that return a pointer with the name of every obj in the folder, but now, i don't know how to read the content of the pointer to just print it in a console, my function look like this  </p>
  
  <pre><code>string* listdir (const char *path)
  {
      string* result = new string[50]; // limit to 50 obj
      DIR *pdir = NULL;
      pdir = opendir (path);
      struct dirent *pent = NULL;
      if (pdir == NULL)
      { 
          printf ("\nERROR! pdir could not be initialised correctly");
          return NULL;
      } 
      int i = 0;
      while (pent = readdir (pdir))
      {
          if (pent == NULL)
          {
              printf ("\nERROR! pent could not be initialised correctly");
              return NULL;
          }
          //printf ("%s\n", pent-&gt;d_name);
          result[i++]= pent-&gt;d_name;
      }
  
      closedir (pdir);
      return result;
  }
  </code></pre>
  
  <p>i've been trying to print the result of teh function  </p>
  
  <pre><code>int main()
  {
      string *dirs;
      dirs = listdir("c:\\");
      int i = 0;
      //while(dirs[i])
      //{
              //cout&lt;&lt;dirs[i]&lt;&lt;'\n';
              //++i;
      //}
  }
  </code></pre>
  
  <p>but i really don't know what i'm doing, lol, some help would be perfect
  thanks</p>