memcpy momove strcmp源码实现
void *memcpy(void *des, void *src, int count)
{
assert(des!=NULL||src!=NULL);
char *d = (char*)des;
char *s = (char*)src;
while(count--)
{
*d++=*s++;
}
return des;
}
void *memove(void *des, void *src, int count)
{
assert(des!=NULL||src!=NULL);
char *d = (char*)des;
char *s = (char*)src;
if ((d <= s) || d>=s+n))
{
while(count--)
{
*d++=*s++;
}
}
else
{
s+=count;
d+=count;
while(count--)
{
*d-- = *s--
}
}
return des;
}
char *strcpy(char *des, const char *src)
{
assert(des!=NULL||src!=NULL);
char *d = des;
while((*d++=*src++) != '\0');
return des;
}