-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memcpy.c
46 lines (41 loc) · 1.44 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: masoares <masoares@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/02 19:28:03 by masoares #+# #+# */
/* Updated: 2023/10/08 11:33:13 by masoares ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
void *ft_memcpy(void *dest, const void *src, size_t n)
{
const char *s;
unsigned int i;
unsigned char *d;
s = src;
d = dest;
i = 0;
if (s == NULL && d == NULL)
return (dest);
while (i < n)
{
*(d + i) = *(s + i);
i++;
}
return (d);
}
/*
#include <stdio.h>
#include <string.h>
int main () {
const char src[50] = "https://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);
}*/