-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
41 lines (38 loc) · 1.25 KB
/
ft_memmove.c
File metadata and controls
41 lines (38 loc) · 1.25 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memmove.c :+: :+: */
/* +:+ */
/* By: ivork <ivork@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/10/29 13:51:26 by ivork #+# #+# */
/* Updated: 2021/10/12 19:54:33 by ivork ######## odam.nl */
/* */
/* ************************************************************************** */
#include <stddef.h>
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned long i;
unsigned long x;
x = n;
i = 0;
if (!src && !dest)
return (0);
if (dest > src)
{
while (x > 0)
{
((char *)dest)[x - 1] = ((const char *)src)[x - 1];
x--;
}
}
else
{
while (i < n)
{
((char *)dest)[i] = ((const char *)src)[i];
i++;
}
}
return (dest);
}