-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
45 lines (39 loc) · 1.42 KB
/
ft_memcpy.c
File metadata and controls
45 lines (39 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marvin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/19 18:32:50 by marvin #+# #+# */
/* Updated: 2022/06/22 16:42:05 by aettouha ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
unsigned char *d;
unsigned char *s;
if (!dest && !src)
return (NULL);
d = (unsigned char *)dest;
s = (unsigned char *)src;
i = 0;
while (i < n)
{
d[i] = s[i];
i++;
}
return (dest);
}
/*int main()
{
char dest[50];
strcpy(dest, "Helloooo!!");
const char src[50] = "http://www.42barcelonatef.com";
printf("Before memcpy dest = %s\n", dest);
ft_memcpy(dest, src, 12);
printf("After memcpy dest = %s\n", dest);
return (0);
}*/