-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memcpy.c
47 lines (42 loc) · 1.46 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
43
44
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rnarciso <rnarciso@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 09:35:59 by merlin #+# #+# */
/* Updated: 2022/11/22 08:09:25 by rnarciso ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
char *temp1;
char *temp2;
size_t i;
i = 0;
temp1 = (char *)src;
temp2 = (char *)dest;
if (temp1 == NULL && temp2 == NULL)
return (0);
while (i < n)
{
temp2[i] = temp1[i];
i++;
}
return (dest);
}
/*
#include <stdio.h>
#include <string.h>
int main () {
const char src[50] = "http://www.tutorialspoint.com";
char dest[50];
strcpy(dest,"Heloooo!!");
printf("Before memcpy dest = %s\n", dest);
ft_memcpy(dest, src, strlen(src)+1);
printf("After memcpy dest = %s\n", dest);
return(0);
}
*/