====== strncpy ====== #include char *strncpy(char *str1, const char *str2, size_t n); Copy a given Number of Chars into another string. #include /* including standard library */ //#include /* uncomment this for Windows */ #include #define MAX 5 int main( void ) { char string1[MAX]; char string2[]="Test 12345"; strncpy(string1, string2, MAX); /* Copy MAX chars from string2 to string1 */ string1[MAX]='\0'; /* Terminate String */ printf("string1 %s\n",string1); return 0; } Output: user@host:~$ ./strncpy string1 Test