-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
39 lines (37 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: macelik <macelik@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 12:28:03 by macelik #+# #+# */
/* Updated: 2023/02/15 12:44:40 by macelik ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
char *d;
char *s;
i = 0;
d = ((char *)dst);
s = ((char *)src);
if (!dst && !src)
return (0);
if (d > s)
{
while (len > 0)
{
d[len -1] = s[len - 1];
len--;
}
}
while (len--)
{
d[i] = s[i];
i++;
}
return ((void *)dst);
}