-
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.33 KB
/
Copy pathft_memmove.c
File metadata and controls
42 lines (39 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jinseo <jinseo@student.42gyeongsan.kr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/28 15:33:56 by jinseo #+# #+# */
/* Updated: 2024/02/28 17:09:27 by jinseo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t cnt;
size_t ncpy;
size_t nncpy;
cnt = 0;
ncpy = n;
nncpy = n;
while (cnt < n)
{
if (dest == (src + cnt))
{
while (ncpy-- > 0)
*(unsigned char *)(dest + ncpy) = \
*(unsigned char *)(src + --nncpy);
return (dest);
}
cnt++;
}
cnt = 0;
while (cnt < n)
{
*(unsigned char *)(dest + cnt) = *(unsigned char *)(src + cnt);
cnt++;
}
return (dest);
}