-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
56 lines (50 loc) · 1.51 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
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edegraev <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 09:01:20 by edegraev #+# #+# */
/* Updated: 2023/11/16 09:00:26 by edegraev ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
char *d;
const char *s;
size_t i;
if (!dest && !src)
return (NULL);
d = dest;
s = src;
i = 0;
while (i < n)
{
d[i] = s[i];
i++;
}
return (dest);
}
// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// int main(void)
// {
// int array [] = { 54, 85, 20, 63, 21 };
// int *copy;
// int length = sizeof( int ) * 5;
// int i;
// copy = (int*)malloc(length);
// ft_memcpy(copy, array, length);
// i = 0;
// while(i < 5)
// {
// printf( "%d ", copy[ i ] );
// i++;
// }
// printf( "\n" );
// free( copy );
// return 0;
// }