-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
56 lines (50 loc) · 1.53 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
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: iziane <iziane@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/10 16:54:07 by iziane #+# #+# */
/* Updated: 2024/03/14 00:29:01 by iziane ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
unsigned char *d;
const unsigned char *s;
size_t i;
if (dst == NULL && src == NULL)
return (NULL);
d = (unsigned char *)dst;
s = (unsigned char *)src;
if (d > s)
{
while (len-- > 0)
d[len] = s[len];
}
else
{
i = 0;
while (len-- > 0)
{
d[i] = s[i];
i++;
}
}
return (dst);
}
// int main(void)
// {
// char src[] = "sdfg";
// char dst[100];
// char src2[] = "sdfg";
// char dst2[100];
// printf("MY: %zu\n", ft_memmove(dst, src, 5));
// printf("OG: %zu\n", memmove(dst2, src2, 5));
// }
// {
// size_t i;
// const char *src_ptr;
// char *dst_ptr;