init
This commit is contained in:
37
libftx/libft/ft_memmove.c
Normal file
37
libftx/libft/ft_memmove.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memmove.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/09/27 11:44:12 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/09/28 16:40: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;
|
||||
|
||||
if (dest == NULL && src == NULL)
|
||||
return (dest);
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user