title: Proper way to copy C strings
body: <p>Is there an easy way to copy C strings?</p>
  
  <p>I have <code>const char *stringA</code>, and I want <code>char *stringB</code> to take the value (note that <code>stringB</code> is not <code>const</code>). I tried <code>stringB=(char*) stringA</code>, but that makes <code>stringB</code> still point to the same memory location, so when <code>stringA</code> later changes, <code>stringB</code> does too.</p>
  
  <p>I've also tried <code>strcpy(stringB,stringA)</code>, but it seems that if <code>stringB</code> wasn't initialized to a large enough array, there's a segfault. I'm not super experienced with C strings though, am I missing something obvious?</p>
  
  <p>If I just initialize <code>stringB</code> as <code>char *stringB[23]</code>, because I know I'll never have a string longer than <code>22</code> characters (and allowing for the null terminator), is that the right way? If <code>stringB</code> is checked for equality with other C-strings, will the extra space affect anything?</p>
  
  <p>(And just using strings isn't a solution here, as I need minimal overhead and easy access to individual characters.)</p>