-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memmove.c
41 lines (38 loc) · 1.26 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
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fozerdem <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/05 10:25:56 by fozerdem #+# #+# */
/* Updated: 2023/07/08 10:16:20 by fozerdem ### ########.tr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *s1, const void *s2, size_t n)
{
size_t len;
len = 0;
if (!s2 && !s1)
return (NULL);
if (s2 < s1)
{
len = n;
while (len > 0)
{
len--;
((unsigned char *)s1)[len] = ((unsigned char *)s2)[len];
}
}
else
{
len = 0;
while (len < n)
{
((unsigned char *)s1)[len] = ((unsigned char *)s2)[len];
len++;
}
}
return (s1);
}