-
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: jergoh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/21 10:24:47 by jergoh #+# #+# */
/* Updated: 2023/09/21 10:24:48 by jergoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t count;
if (dest == src || !n)
return (dest);
count = 0;
if (dest < src)
{
while (count < n)
{
*((char *)dest + count) = *((char *)src + count);
count++;
}
}
else
{
while (n > 0)
{
*((char *)dest + n - 1) = *((char *)src + n - 1);
n--;
}
}
return (dest);
}