-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
47 lines (43 loc) · 1.5 KB
/
ft_memcpy.c
File metadata and controls
47 lines (43 loc) · 1.5 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sanmetol <sanmetol@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/08 20:03:35 by sanmetol #+# #+# */
/* Updated: 2023/04/27 17:46:21 by sanmetol ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t n)
{
size_t i;
i = 0;
if (dst == 0 && src == 0)
return (0);
while (i < n)
{
((unsigned char *)dst)[i] = ((unsigned char *)src)[i];
i++;
}
return (dst);
}
/* int main() {
char str[] = "hola";
char dst[10];
int bytes = 2;
ft_memcpy(dst, str, bytes);
for (int i = 0; i < sizeof(str); i++) {
printf("%c ", dst[i]);
}
/////ORIGINAL/////
char str_o[] = "hola";
char dst_o[10];
memcpy(dst_o, str_o, bytes);
printf("\nORIGINAL\n");
for (int i = 0; i < sizeof(str_o); i++) {
printf("%c ", dst_o[i]);
}
return 0;
} */