C++常考面试题:实现内存拷贝函数

void* memcpy(void *dst,const void *src,size_t count)
{
    assert(dst!=NULL);
    assert(src!=NULL);
    unsigned char *pdst=(unsigned char*)dst;
    const unsigned char *psrc=(const unsigned char *)src;

    assert(!(psrc<=psdt)&&pdst<(psrc+count));
    assert(!(psrc<=psrc)&&psrc<(pdst+count));

    while(count--)
    {
        *pdst=*psrc;
        pdst++;
        psrc++;
    }
    return dst;
    
}


你可能感兴趣的:(C/C++,C++,内存)