-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
46 lines (43 loc) · 1.66 KB
/
ft_memcpy.c
File metadata and controls
46 lines (43 loc) · 1.66 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nholbroo <nholbroo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/13 15:38:26 by nholbroo #+# #+# */
/* Updated: 2025/02/03 16:20:01 by nholbroo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Which function:
Equivalent to the function "memcpy" in string.h.
Definition:
The memcpy() function copies n bytes from memory area src to memory
area dest. The memory areas must not overlap.
Return values:
Returns a pointer to dest.
@param src A pointer to the start of the original memory.
@param dest A pointer to the start of the copied memory.
@param n How many bytes to be copied.
@param srcptr Making srcptr point to src, with the purpose of typecasting. Same
applies to destptr.
*/
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
unsigned char *destptr;
const unsigned char *srcptr;
i = 0;
if (dest == NULL && src == NULL)
return (NULL);
srcptr = src;
destptr = dest;
while (i < n)
{
destptr[i] = srcptr[i];
i++;
}
return (dest);
}