title: vector of char stars in c++
body: <p>If I declare a vector as such:</p>
  
  <p><code>vector&lt;char *&gt; charStarVec(4);</code></p>
  
  <p>and then add values to it like so:</p>
  
  <pre><code>charStarVec.at(0) = (char *) "one";
  charStarVec.at(1) = (char *) "two";
  charStarVec.at(2) = (char *) "three";
  charStarVec.at(3) = (char *) "four";
  </code></pre>
  
  <p>Then no problems result. (I can print out all the vector elements just fine.)</p>
  
  <p>But I get problems if I use character arrays (to get the data off the disk.)</p>
  
  <p>The program crashes if I try to memcpy/strcpy/assign from a character array to a character pointer. </p>
  
  <pre><code>char *c = "blah";
  char carr[5];
  ...
  c[0] = carr[0];           //FAIL (crashes at runtime)
  memcpy(c,carr,5);         //FAIL (crashes at runtime)
  strcpy(c,carr,5);         //FAIL (crashes at runtime)
  ...
  charStarVec.at(i) = carr; //FAIL (all 4 elements are the same as the last element.)
  charStarVec.at(i) = c;
  
  </code></pre>
  
  <p>But how else am I supposed to get a vector of character pointers to data that is a copy of what was on the disk, which is variable sized and may not terminate in a null character, thus requiring me to manually add the null character.</p>
  
  <p>I am fairly new to c/c++, in case it wasn't obvious.</p>