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?
otherString
#include <string.h> ... char otherString[6]; // note 6, not 5, there's one there for the null terminator ... strncpy(otherString, someString, 5); otherString[5] = ''; // place the null terminator
1.4m articles
1.4m replys
5 comments
57.0k users