-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
40 lines (37 loc) · 1.46 KB
/
ft_memcpy.c
File metadata and controls
40 lines (37 loc) · 1.46 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jowagner <jowagner@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/12 14:02:21 by jowagner #+# #+# */
/* Updated: 2024/12/12 19:49:30 by jowagner ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief Copies n bytes from memory area src to memory area dest.
*
* @param dest Pointer to the destination memory area.
* @param src Pointer to the source memory area.
* @param n Number of bytes to copy.
* @return A pointer to dest.
*/
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
unsigned char *dest_data;
unsigned const char *src_data;
dest_data = (unsigned char *)dest;
src_data = (unsigned const char *)src;
if (!src_data && !dest_data)
return (NULL);
i = 0;
while (i < n)
{
dest_data[i] = src_data[i];
i++;
}
return (dest);
}