这是代码:
void *ft_memcpy(void *dst, const void *src, size_t n)
{
unsigned char *to;
unsigned char *from;
if (dst == NULL && src == NULL)
return (NULL);
if (dst == src)
return (dst);
to = (unsigned char *)dst;
from = (unsigned char *)src;
while (n--)
*to++ = *from++ ;
return (dst);
}
我想知道如果我们在这个函数中使用
char
而不是 unsigned char
是否会有区别:
void *ft_memcpy(void *dst, const void *src, size_t n)
{
char *to;
char *from;
if (dst == NULL && src == NULL)
return (NULL);
if (dst == src)
return (dst);
to = (char *)dst;
from = (char *)src;
while (n--)
*to++ = *from++ ;
return (dst);
}
如果存在差异,请展示这些函数表现不同的情况。