#include <stdio.h>
#include <stdlib.h>
char * mymemcpy(char* dest, char* source, size_t count);
int main(void)
{
char str[] = "0123456789";
mymemcpy( str+3, str+1, 5 );
printf("here is : %s",str);
return 0;
}
char* mymemcpy(char* dest, char* source, size_t count)
{
char* ret = dest;
if (ret <= source || ret >= (source + count))
{
while (count --)
*dest++ = *source++;
}
else
{
dest += count - 1;
source += count - 1;
while (count--)
*dest-- = *source--;
}
return ret;
}