-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
36 lines (33 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: javellis <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 12:15:13 by javellis #+# #+# */
/* Updated: 2022/10/04 12:15:17 by javellis ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, unsigned int n)
{
unsigned int i;
char *p_dest;
char *p_src;
i = 0;
p_dest = (char *)dest;
p_src = (char *)src;
if (p_src < p_dest)
while (n-- > 0)
p_dest[n] = p_src[n];
else
{
while (i < n)
{
p_dest[i] = p_src[i];
i++;
}
}
return (dest);
}