-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
42 lines (39 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mem_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dskrypny <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/10/31 10:45:30 by dskrypny #+# #+# */
/* Updated: 2017/11/18 14:25:33 by dskrypny ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t i;
unsigned const char *str;
unsigned char *dest;
dest = (unsigned char *)dst;
str = (unsigned const char *)src;
if (dest <= str)
{
i = 0;
while (i <= len)
{
dest[i] = str[i];
i++;
}
}
else
{
i = len;
while (i > 0)
{
dest[i - 1] = str[i - 1];
i--;
}
}
return (dst);
}