title: C++ char** -> vector<string> -> string -> char** parsing problem
body: <p>Lets say that I'm trying to solve a parsing problem of string to char **
  For some reason the below code generates a lot of trash, can anyone have a look at it please?</p>
  
  <ol>
  <li>Here's what it's supposed to do :</li>
  <li>Dump all argv into a string_array
  container</li>
  <li>Dump everything in the string_array
  container into a std::string and
  separate with spaces</li>
  <li>Break the string down into string
  tokens using boost/algorithm/string</li>
  <li>create a new char ** and dump all
  tokens into it, print out the new char **, clean up </li>
  </ol>
  
  <p>What have I done wrong ?</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  #include &lt;boost/algorithm/string.hpp&gt;
  
  using namespace std;
  using namespace boost;
  
  typedef vector&lt;string&gt; string_array;
  
  int main(int argc, char ** argv)
  {
      string_array args;
      string_array tokens;
      cout &lt;&lt; "Real arguments :" &lt;&lt; endl;
      for(int i = 0; i &lt; argc; i++)
      { cout &lt;&lt; argv[i] &lt;&lt; endl;}
  
      string arg = "";
      for(int i = 1; i &lt; argc; i++)
      {
          args.push_back(argv[i]);
      }
      for(int i = 0; i &lt; (int)args.size(); i++)
      {
          arg += args[i];
          if(i != (int)args.size() - 1)
              arg += " ";
      }
  
      split(tokens, arg, is_any_of(" "));
  
      char ** new_args = NULL;
      new_args = new char*[(int)tokens.size()];
      for(int i = 0; i &lt; (int)tokens.size(); i++)
      { 
          new_args[i] = new char[(int)tokens[i].size()];
          for(int j = 0; j &lt; (int)tokens[i].size(); j++)
          {
              new_args[i][j] = tokens[i][j];
          }
      }
  
      for(int i = 0; i &lt; (int)tokens.size(); i++)
      { std::cout &lt;&lt; new_args[i] &lt;&lt; std::endl; }
      delete [] new_args;
  }
  </code></pre>