feat: add ft_memmove function

memmove:
	if the src pointer is higher than the dst pointer,
	the function copies each caracter backwards.
This commit is contained in:
2025-10-04 14:43:15 +02:00
parent bfbee5b3a9
commit b88037b15a
2 changed files with 27 additions and 0 deletions

18
ft_memmove.c Normal file
View File

@@ -0,0 +1,18 @@
#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);
}