strncpy copies upto null or specified no. of bytes whichever is less. But memcpy overlooks null and copies all specified no. of bytes.
None of them adds null in destination string by itself.
#include<conio.h>
#include<memory.h>
#include<string.h>
void main()
{
char str1[50] "This is india: a wonderful country";
char str2[30];
printf(" s" str1);
strncpy(str2 str1 15);
//memcpy(str2 str1 15);
//str2[12] ' ';
printf("n s" str2);
printf("n c c" str2[12] str2[13]);
getch();
}
str1[8] is null. As strncpy copies upto null str[12] and str[13] takes value as blank.
In case of memcpy as all the specifed 15 bytes are copied in the destination string
str[12] takes 'i' and str[13] takes 'a' as values.