void * memmove (void *dest, const void *src, size_t len)
{
if (NULL == dest || NULL == src || len <= 0)
return NULL;
char *d = dest;
const char *s = src;
if (d < s)
while (len--)
*d++ = *s++;
else
{
char *lasts = s + (len-1);
char *lastd = d + (len-1);
while (len--)
*lastd-- = *lasts--;
}
return dest;
}
注意memcpy与memmove 处理重叠内存方式不一样