-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
38 lines (35 loc) · 1.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: acalin-b <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/13 14:02:12 by acalin-b #+# #+# */
/* Updated: 2023/03/22 10:46:27 by acalin-b ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
char *p_src;
char *p_dest;
int i;
i = 0;
p_src = (char *)src;
p_dest = (char *)dest;
if (dest == NULL && src == NULL)
return (NULL);
if (p_src < p_dest)
while (n--)
p_dest[n] = p_src[n];
else
{
while (i < n)
{
p_dest[i] = p_src[i];
i++;
}
}
return (p_dest);
}