-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
40 lines (36 loc) · 1.34 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: taretiuk <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/18 11:47:55 by taretiuk #+# #+# */
/* Updated: 2023/12/04 10:52:28 by taretiuk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
unsigned char *d;
const unsigned char *s;
if (dest == NULL && src == NULL)
return (0);
d = (unsigned char *)dest;
s = (unsigned char *)src;
while (n-- > 0)
{
*(d++) = *(s++);
}
return (dest);
}
/*
int main(void)
{
char mem[30];
if (mem != ft_memcpy(mem, "zyxwvutsrqponmlkjihgfedcba", 14))
write(1, "dest's adress was not returned\n", 31);
write(1, mem, 30);
return (0);
}
*/