void* mymemcpy(void *dest, const void *src, size_t count)
{
char* pdest = static_cast<char*>(dest);
const char* psrc = static_cast<const char*>(src);
if (pdest > psrc && pdest < (char*)psrc + count ) //能考虑到这种情况就行了
{
for (size_t i = count - 1; i != -1; --i)
pdest[i] = psrc[i];
}
else
{
for (size_t i = 0; i < count; ++i)
pdest[i] = psrc[i];
}
return dest;
}
网友评论