Files
42_INT_01_libft/srcd/part1/ft_memmove.c

36 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:56:25 by hulamy #+# #+# */
/* Updated: 2019/11/25 13:56:29 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** copy n characters from src to dst in a non destructive way and return dst
*/
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
int i;
char *source;
char *dest;
i = -1;
source = (char *)src;
dest = (char *)dst;
if (source < dest)
while ((int)(--len) >= 0)
dest[len] = source[len];
else
while (++i < (int)len)
dest[i] = source[i];
return (dst);
}