-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
50 lines (46 loc) · 1.33 KB
/
ft_memmove.c
File metadata and controls
50 lines (46 loc) · 1.33 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
43
44
45
46
47
48
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thfranco <thfranco@student.42.rio> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 11:26:31 by thfranco #+# #+# */
/* Updated: 2023/11/04 11:26:33 by thfranco ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
char *d;
char *s;
i = 0;
s = (char *)src;
d = (char *)dest;
if (d < s)
{
while (i < n)
{
d[i] = s[i];
i++;
}
}
else if (d > s)
{
i = n;
while (i > 0)
{
d[i - 1] = s[i - 1];
i--;
}
}
return (dest);
}
/*int main(void)
{
char s[100];
ft_memmove(s,"ola",3);
printf("%s", s);
return (0);
}*/