-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
65 lines (62 loc) · 1.71 KB
/
Copy pathft_memcpy.c
File metadata and controls
65 lines (62 loc) · 1.71 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpadenko <dpadenko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/05 18:47:56 by dpadenko #+# #+# */
/* Updated: 2023/09/15 22:10:08 by dpadenko ### ########.fr */
/* */
/* ************************************************************************** */
//#include <string.h>
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
unsigned char *start;
start = (unsigned char *)dest;
if (!dest && !src)
return (0);
while (n)
{
*(unsigned char *)dest = *(unsigned char *)src;
n--;
src++;
dest++;
}
return (start);
}
/*
#include <stdio.h>
#include <stdio.h>
int main(void)
{
char src[] = "source string";
char dest[20];
dest[0] = src[3];
printf("dest before:%s\n", dest);
printf("src before:%s\n", src);
ft_memcpy(dest, src, 5);
printf("dest string1:%s\n", dest);
memcpy(dest, src, 5);
printf("dest string2:%s", dest);
}
*/
/*
int main(void)
{
char src[] = "source string";
char dest[20];
memcpy(dest, src, 5);
printf("dest string:%s", dest);
}
*/
/*
int main(void)
{
int a = 2;
int b = 3;
memcpy(&a,&b, 1);
printf("%d", a);
}
*/