-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
41 lines (38 loc) · 1.21 KB
/
Copy pathft_memcpy.c
File metadata and controls
41 lines (38 loc) · 1.21 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_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jihyjeon < jihyjeon@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/11 13:51:03 by jihyjeon #+# #+# */
/* Updated: 2023/11/05 21:46:56 by jihyjeon ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t n)
{
unsigned char *d;
unsigned char *s;
d = dst;
s = (unsigned char *)src;
if (!d && !s)
return (0);
if (d < s || d >= (s + n))
{
while (n--)
{
*(d++) = *(s++);
}
}
else
{
d += n;
s += n;
while (n--)
{
*(--d) = *(--s);
}
}
return (dst);
}