title: How to convert std::vector<char*> to char**?
body: <p>I'm trying to convert a vector of c strings to an array of c strings. I tried this but it does not appear to work right:</p>
  
  <pre><code>int glfxGetProgramList(int effect, char** progList, int* count)
  {
      std::vector&lt;char*&gt; list;
      gEffects[effect]-&gt;GetProgramList(list);
      fprintf(stderr, "Lib Output: %s\n", list[0]);
      progList = &amp;list[0];
      int size = list.size();
      memcpy(count, &amp;size, sizeof(int));
  }
  </code></pre>
  
  <p>The debug output returned from stderr is correct inside the function. However, when I use this function inside my project and try to output the first item in the list it crashes with a segmentation fault. Here is the code in my project:</p>
  
  <pre><code>char ** list;
  int size;
  glfxGetProgramList(effect, list, &amp;size );
  fprintf(stderr, "Output: %s\n", list[0]);
  </code></pre>
  
  <p>Any idea what I'm doing wrong?</p>
  
  <p>EDIT:</p>
  
  <p>I think I'm going to have to start at the base of the problem. There is a private map array which I'm trying to get the list of names from. Here is the code for GetProgramList:</p>
  
  <pre><code>unsigned Effect::GetProgramList(vector&lt;char*&gt;&amp; list) const
  {
      for(map&lt;string,Program*&gt;::const_iterator it=m_programs.begin(); it!=m_programs.end(); ++it)
          list.push_back( (char*)it-&gt;first.c_str() );
  }
  </code></pre>