What is the difference between memcpy()
and strcpy()
? I tried to find it with the help of a program but both are giving the same output.
int main()
{
char s[5] = { 's', 'a', '\0', 'c', 'h' };
char p[5];
char t[5];
strcpy(p, s);
memcpy(t, s, 5);
printf("sachin p is [%s], t is [%s]", p, t);
return 0;
}
Output
sachin p is [sa], t is [sa]