strncpy in c

strcpy() function copies only specified number of charcters in the string to other.here the main point is the destination string size should be greater than size of the source string.if there are any characters in destination string those will be deleted and source string characters will be replaced.

syntax:

strcpy(s1,s2,n);

n characters are copied from string to str1 and appended from starting of string

example:

#include
#include
void main()
{
char x[20],y[20]="codeskulls";
printf("enter string one");
gets(x);
puts(y);
strncpy(y,x,4);
puts(y);
}