Copying a part of a string (substring) in C

c

Solution

#include <string.h>
...
char otherString[6]; // note 6, not 5, there's one there for the null terminator
...
strncpy(otherString, someString, 5);
otherString[5] = '\0'; // place the null terminator

Problem

I have a string: ``` char * someString; ``` If I want the first five letters of this string and want to set it to `otherString`, how would I do it?

Original source