42_libft/ft_memmove.c

36 lines
1.2 KiB
C
Raw Normal View History

2022-09-27 10:29:23 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 11:44:12 by cchauvet #+# #+# */
/* Updated: 2022/09/27 14:14:24 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
char *tab1;
char *tab2;
tab1 = dest;
tab2 = (void *) src;
if (tab1 < tab2)
ft_memcpy(dest, src, n);
else
{
i = n;
while (0 < i)
{
i--;
tab1[i] = tab2[i];
}
}
return (dest);
}