-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
41 lines (37 loc) · 1.52 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kczichow <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/23 11:35:12 by kczichow #+# #+# */
/* Updated: 2022/05/04 10:17:54 by kczichow ### ########.fr */
/* */
/* ************************************************************************** */
/* FT_MEMCPY
* -----------
* DESCRIPTION
* The function function copies n bytes from memory area src to memory area
* dst. If dst and src overlap, behavior is undefined, use ft_memmove instead.
* Void pointer cannot be dereferenced. Therefore new pointer is being created
* which point to the same address.
*/
#include "libft.h"
void *ft_memcpy(void *dst1, const void *src1, size_t n)
{
unsigned char *dst;
unsigned const char *src;
size_t i;
i = 0;
if (dst1 == NULL && src1 == NULL)
return (NULL);
dst = (unsigned char *)dst1;
src = (unsigned const char *) src1;
while (i < n)
{
dst[i] = ((unsigned char *)src)[i];
i++;
}
return (dst1);
}