strcpy v/s memcpy

Posted by Sachin Chourasiya on Stack Overflow See other posts from Stack Overflow or by Sachin Chourasiya
Published on 2010-05-24T16:09:10Z Indexed on 2010/05/24 16:11 UTC
Read the original article Hit count: 592

Filed under:
|

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]

© Stack Overflow or respective owner

Related posts about memcpy

Related posts about strcpy