-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcpy.c
34 lines (31 loc) · 1.25 KB
/
ft_memcpy.c
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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memcpy.c :+: :+: */
/* +:+ */
/* By: cherrewi <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/10/19 15:11:06 by cherrewi #+# #+# */
/* Updated: 2022/10/19 15:11:07 by cherrewi ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Copies n bytes from src to dest.
Src and dest should not overlap; there is no protection.
*/
void *ft_memcpy(void *dst, const void *src, size_t n)
{
void *p_dst_iter;
if (dst == NULL && src == NULL)
return (NULL);
p_dst_iter = dst;
while (n)
{
*(unsigned char *)p_dst_iter = *(unsigned char *)src;
src++;
p_dst_iter++;
n--;
}
return (dst);
}