-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
48 lines (44 loc) · 1.47 KB
/
ft_memmove.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ldel-val <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/19 08:51:46 by ldel-val #+# #+# */
/* Updated: 2024/10/10 19:46:42 by ldel-val ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
if (n == 0)
return (dest);
if (dest < src)
{
i = 0;
while (n--)
{
((char *)dest)[i] = ((char *)src)[i];
i ++;
}
}
else if (dest > src)
while (n--)
((char *)dest)[n] = ((char *)src)[n];
return (dest);
}
/*
int main (void)
{
char src[] = "Lorem ipsum dolor sit amet";
char src2[] = "Lorem ipsum dolor sit amet";
char *dest;
char *dest2;
dest = src + 1;
dest2 = src2 + 1;
printf("Ft: %s\n", (char *)ft_memmove(src, dest, 8));
printf("Or: %s\n", (char *)memmove(src, dest, 8));
return (1);
}*/