-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
executable file
·43 lines (40 loc) · 1.26 KB
/
ft_memmove.c
File metadata and controls
executable file
·43 lines (40 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gyong-si <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/12 12:08:47 by gyong-si #+# #+# */
/* Updated: 2023/09/21 15:05:20 by gyong-si ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
void *ft_memmove(void *dest, void *src, size_t n)
{
size_t i;
char *temp;
if (src == NULL && dest == NULL)
return (NULL);
temp = (char *)dest;
if (src < dest)
{
i = n;
while (i > 0)
{
temp[i - 1] = ((char *)src)[i - 1];
i--;
}
}
else
{
i = 0;
while (i < n)
{
temp[i] = ((char *)src)[i];
i++;
}
}
return (dest);
}