In C, I have two char arrays:
char array1 = "abcdefg";
array2 = array1
You can't directly do
array1 = array2. Because in this case you would manipulate the addresses (
char *) of the arrays and not their values.
// Will copy 18 characters from array1 to array2 strncpy(array2, array1, 18);
As @Prof. Falken mentioned in a comment,
strncpy can be evil. Make sure your target buffer is big enough to contain the source buffer (including the
\0 at the end of the string).