C – Strncpy

C – Strncpy 2017-08-06T09:02:36+00:00

Strncpy :

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.

Syntax :
char *strncpy( char *to, const char *from,size_t count );

C – STRNCPY EXAMPLE PROGRAM :

Output :

Before :

str1 : learner

str2 : mode.com

After :

str1 : mode.learner

str2 : mode.com

Prev Next