C – Strncpy

C – Strncpy 2017-06-12T11:16:10+00:00

strncpy()

Syntax :
#include<string.h>
char *strncpy( char *to, const char *from,size_t count );

strncpy(str1,str2,n) copies up to n characters from the string pointed to by str2 to the string pointed to by str1 and terminates str1 with a null. The str2 must be a pointer to a null terminated string.

Example :

Output :

Before :

str1 : learner

str2 : mode.com

After :

str1 : mode.learner

str2 : mode.com

Prev Next