title: C++ copy const char* to char*
body: <p>I have a function </p>
  
  <pre><code>ClassA::FuncA(const char *filePath)
  </code></pre>
  
  <p>and want to copy this const char string* to a char*!</p>
  
  <p>My solution:</p>
  
  <pre><code>char *argv[2];
  int length = strlen(filePath);
  argv[1] = new char(length +1);
  strncpy(argv[1], filePath, length); 
  </code></pre>
  
  <p>after this I have in argv[1] the desired chars but also some other undefined chars!</p>
  
  <p>filePath: </p>
  
  <blockquote>
    <p>"C:\Users\userA\Parameter.xmlþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþKŸQyá•"</p>
  </blockquote>
  
  <p>Whats wrong here? The length with strlen is OK!</p>