C/C++语言|memcpy的实现


1)注意对输入指针是否为NULL的判断;
2)输入和输出的类型 void *
3)强制将void* 指针转换为char* 再进行拷贝操作

【C/C++语言|memcpy的实现】void * memcpy(void *dest,void *src,unsigned count )
{
if (dest == NULL || src =https://www.it610.com/article/= NULL)
{
return NULL;
}
char* pdest =(char*) dest;
char* psrc = https://www.it610.com/article/(char*)src;
while (count--)
{
*pdest++ = *psrc++;
}
return dest;
}

    推荐阅读