-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
42 lines (38 loc) · 1.56 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
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lclerc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/02 08:47:54 by lclerc #+# #+# */
/* Updated: 2022/11/23 16:11:57 by lclerc ### ########.fr */
/* */
/* ************************************************************************** */
/*
* memcpy() copies n bytes from memory area src to memory area dst. If dst and
* src overlap, behaviour is undefined, even though some compilers may handle
* it. This is the main difference with memmove(), which can handle overlapping
* memory addresses using a buffer. See memmove()
*
* memcpy() function returns the original value of dst.
*
*/
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t n)
{
unsigned char *source;
unsigned char *destination;
source = (unsigned char *)src;
destination = (unsigned char *)dst;
if (!source && !destination)
return (NULL);
while (n)
{
*destination = *source;
destination++;
source++;
n--;
}
return (dst);
}