mirror of
https://github.com/guezoloic/libft.git
synced 2026-01-25 07:34:16 +00:00
memmove: if the src pointer is higher than the dst pointer, the function copies each caracter backwards.
19 lines
239 B
C
19 lines
239 B
C
#include "libft.h"
|
|
|
|
void *ft_memmove(void *dst, const void *src, size_t len)
|
|
{
|
|
if (dst <= src)
|
|
{
|
|
ft_memcpy(dst, src, len);
|
|
}
|
|
else
|
|
{
|
|
while (len > 0)
|
|
{
|
|
len--;
|
|
((char *)dst)[len] = ((char *)src)[len];
|
|
}
|
|
}
|
|
return (dst);
|
|
}
|