-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
42 lines (38 loc) · 1.36 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gudaniel <gudaniel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/09 13:57:13 by gudaniel #+# #+# */
/* Updated: 2024/04/09 13:57:19 by gudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
size_t i;
const unsigned char *memsrc;
unsigned char *memdest;
i = 0;
memsrc = (const unsigned char *)src;
memdest = (unsigned char *)dest;
if (!dest && !src)
return (0);
while (n--)
{
memdest[i] = memsrc[i];
i++;
}
return (dest);
}
/* int main()
{
char src[50] = "Gustavo Daniel";
char dest[50];
memcpy(dest, src, strlen(src) + 1);
printf("After memcpy dest = %s\n", dest);
return (0);
}
*/