-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
42 lines (39 loc) · 1.32 KB
/
Copy pathft_memmove.c
File metadata and controls
42 lines (39 loc) · 1.32 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alexfran <alexfran@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/13 12:40:12 by alexfran #+# #+# */
/* Updated: 2025/12/01 16:06:13 by alexfran ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned char *a;
const unsigned char *b;
size_t i;
i = 0;
a = (unsigned char *)dest;
b = (const unsigned char *)src;
if (a == b)
return (dest);
if (a < b)
{
while (i < n)
{
((unsigned char *)dest)[i] = ((unsigned char *)src)[i];
i++;
}
}
else
{
while (n-- > 0)
{
((unsigned char *)dest)[n] = ((unsigned char *)src)[n];
}
}
return (dest);
}