-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
39 lines (35 loc) · 1.35 KB
/
ft_memcpy.c
File metadata and controls
39 lines (35 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kmoutaou <marvin@.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/04 13:36:24 by kmoutaou #+# #+# */
/* Updated: 2021/11/19 16:17:52 by kmoutaou ### ########.fr */
/* */
/* ************************************************************************** */
/*
ft_memcpy is a re-coded memcpy function from <string.h> that copies a
block of memory from a location to another. n is the number of bytes to
be copied.
*/
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
unsigned char *dest0;
const unsigned char *src0;
unsigned int i;
i = 0;
if (!dest && !src)
return (NULL);
dest0 = (unsigned char *)dest;
src0 = (const unsigned char *)src;
while (n)
{
dest0[i] = src0[i];
i++;
n--;
}
return (dest);
}