-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
38 lines (34 loc) · 1.3 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
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aviholai <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/26 14:42:06 by aviholai #+# #+# */
/* Updated: 2022/02/08 14:40:03 by aviholai ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** 'Memcpy' (memory copy) function copies 'n' amount of bytes from memory area
** 'src' to memory area 'dst'. If 'dst' and 'src' overlap, behavior is
** undefined.
*/
void *ft_memcpy(void *dst, const void *src, size_t n)
{
size_t i;
char *s1;
if (dst == NULL && src == NULL)
return (NULL);
i = 0;
s1 = (char *)dst;
while (i < n)
{
*(char *)s1 = *(char *)src;
s1++;
src++;
i++;
}
return (dst);
}