-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
53 lines (48 loc) · 1.45 KB
/
ft_memcpy.c
File metadata and controls
53 lines (48 loc) · 1.45 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
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mobouifr <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/11 21:09:38 by mobouifr #+# #+# */
/* Updated: 2023/12/11 10:51:17 by mobouifr ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t n)
{
size_t i;
unsigned char *f;
const unsigned char *s;
if (src == NULL && dst == NULL)
return (NULL);
if (src == dst)
return (dst);
f = (unsigned char *)dst;
s = (const unsigned char *)src;
i = 0;
while (i < n)
{
f[i] = s[i];
i++;
}
return (f);
}
/*
#include "libft.h"
#include <stdio.h>
int main(void)
{
int src[] = {1, 1, 1, 1, 1};
int dst[] = {0, 0, 0, 0, 0};
size_t i = 0;
ft_memcpy(dst + 2, src, 8);
while (i < 5)
{
printf("%d ", dst[i]);
i++;
}
return 0;
}
*/