-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
39 lines (36 loc) · 1.24 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: rvan-mee <rvan-mee@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2022/03/05 13:12:26 by rvan-mee #+# #+# */
/* Updated: 2022/03/05 13:12:27 by rvan-mee ######## odam.nl */
/* */
/* ************************************************************************** */
#include <stddef.h>
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
i = 0;
if (!dst && !src)
return (0);
if (src > dst)
{
while (i < len)
{
((unsigned char *) dst)[i] = ((unsigned char *) src)[i];
i++;
}
}
else
{
while (len)
{
((unsigned char *) dst)[len - 1] = ((unsigned char *) src)[len - 1];
len--;
}
}
return (dst);
}