-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
39 lines (36 loc) · 1.41 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rruiz-sa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/16 17:25:21 by rruiz-sa #+# #+# */
/* Updated: 2022/10/13 21:02:09 by rruiz-sa ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t len)
{
size_t i;
char *str_dst;
char *str_src;
if (!dst && !src)
return (NULL);
str_dst = (char *)dst;
str_src = (char *)src;
i = 0;
while (i < len)
{
str_dst[i] = str_src[i];
i++;
}
return ((void *) str_dst);
}
/*
1- Check if the dst and src exist
2- Create new string with the value of dst and other with src
3- Iterates up to the parameter passed by the function(len)
4- Every iteration copy the value of source inside destination
5- Return destination
*/