-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcpy.c
48 lines (41 loc) · 1.33 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
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpouget <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/14 17:04:37 by tpouget #+# #+# */
/* Updated: 2020/05/26 15:44:13 by tpouget ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
unsigned char *d;
unsigned char *s;
i = 0;
d = (unsigned char*)dest;
s = (unsigned char *)src;
if (!d && !s)
return (NULL);
while (i < n)
{
d[i] = s[i];
i++;
}
return (dest);
}
/*
#include <unistd.h>
#include <string.h>
int main(void)
{
char arr[] = "Hello";
ft_memcpy(arr, "World", 3);
write(1, arr, sizeof arr);
write(1, "\n", 1);
return 0;
}
*/