-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
50 lines (46 loc) · 1.32 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
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-haib <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 13:13:45 by ael-haib #+# #+# */
/* Updated: 2024/02/21 19:22:03 by ael-haib ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t len)
{
unsigned char *d;
const unsigned char *s;
d = dest;
s = src;
if (d == s)
return (dest);
if (d < s || d >= s + len)
{
while (len--)
{
*d++ = *s++;
}
}
else
{
d += len - 1;
s += len - 1;
while (len--)
{
*d-- = *s--;
}
}
return (dest);
}
/* int main()
{
char d[] = "";
char s[] = "";
ft_memmove(d, s, 9);
printf("%s", d);
return (0);
} */