title: returning array of char pointers from a function (c++)
body: <p>I'm trying to return an array of <code>char</code> arrays.  While I am able to create the array succesfully, I am apparently returning it incorrectly. </p>
  
  <p>Is my syntax off or am I committing some other error that I am overlooking? </p>
  
  <p>Here are the most relevant lines, the full functions follow </p>
  
  <pre><code>// prototype
    char * testFunc();
  
  // Function
      char * testFunc() {
        char* ptrArray[2];   
        return(*ptrArray);
      }
  // Assignment in main()
      int main {
        char * res = testFunc();
      }
  </code></pre>
  
  <p>Here is a simplified version of the full code</p>
  
  <pre><code>#include &lt;iostream&gt;
  using std::cout;
  
  // prototype
  char * testFunc();
  
  int main() {
  
      short i, j;
      char * res = testFunc();
  
          for (i=0; i &lt; 2; i++)
             cout &lt;&lt;"This is  res[" &lt;&lt; i &lt;&lt; "] : " &lt;&lt; res[i] &lt;&lt;"\n";
  
  
      return(0);
  }
  
  char * testFunc() {
  
      char word1[] = "one";
      char word2[] = "two";
  
      // create an array of char*
      char* ptrArray[2];
  
      ptrArray[0] = word1;
      ptrArray[1] = word2;
  
      for (int i=0; i&lt;2; i++)
          cout &lt;&lt;"This is ptrArray[" &lt;&lt; i &lt;&lt; "] : " &lt;&lt; ptrArray[i] &lt;&lt;"\n";
  
      return(*ptrArray);
  }
  </code></pre>