mirror of
https://github.com/Ladebeze66/libft.git
synced 2025-12-13 04:36:55 +01:00
43 lines
1.2 KiB
C
Executable File
43 lines
1.2 KiB
C
Executable File
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memmove.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/07 11:11:49 by fgras-ca #+# #+# */
|
|
/* Updated: 2023/02/07 16:04:25 by fgras-ca ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
void *ft_memmove(void *dest, const void *src, size_t n)
|
|
{
|
|
char *destmov;
|
|
char *srcmov;
|
|
size_t i;
|
|
|
|
if (!dest && !src)
|
|
return (0);
|
|
destmov = (char *)dest;
|
|
srcmov = (char *)src;
|
|
i = 0;
|
|
if (destmov > srcmov)
|
|
{
|
|
while (n--)
|
|
{
|
|
destmov[n] = srcmov[n];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
while (n--)
|
|
{
|
|
destmov[i] = srcmov[i];
|
|
i++;
|
|
}
|
|
}
|
|
return (destmov);
|
|
}
|