-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
34 lines (31 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aliwang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/16 07:52:00 by aliwang #+# #+# */
/* Updated: 2019/02/21 10:15:01 by aliwang ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
char *char_dst;
const char *char_src;
i = 0;
char_dst = (char*)dest;
char_src = (char*)src;
if (char_dst > char_src)
while ((int)n-- > 0)
char_dst[n] = char_src[n];
else
while (n > i)
{
char_dst[i] = char_src[i];
i++;
}
return ((void*)dest);
}