-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
40 lines (37 loc) · 1.29 KB
/
ft_memmove.c
File metadata and controls
40 lines (37 loc) · 1.29 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kjungoo <kjungoo@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/13 17:36:11 by kjungoo #+# #+# */
/* Updated: 2022/07/26 20:00:00 by kjungoo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
unsigned char *p_dst;
unsigned char *p_src;
i = 0;
p_dst = (unsigned char *)dst;
p_src = (unsigned char *)src;
if (dst == src || len == 0)
return (dst);
if (dst < src)
{
while (i < len)
{
p_dst[i] = p_src[i];
i++;
}
}
while (i < len)
{
p_dst[len - 1 - i] = p_src[len - 1 - i];
i++;
}
return (dst);
}