Projet de l'école 42 : Libft
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
1.3 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/22 15:17:21 by narnaud #+# #+# */
/* Updated: 2021/11/15 09:01:11 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t n)
{
size_t i;
unsigned char *ptr_dst;
unsigned char *ptr_src;
ptr_dst = (unsigned char *)dst;
ptr_src = (unsigned char *)src;
i = 0;
if (!dst && !src)
return (NULL);
if (ptr_src < ptr_dst)
while (++i <= n)
ptr_dst[n - i] = ptr_src[n - i];
else
while (n--)
*(ptr_dst++) = *(ptr_src++);
return (dst);
}