-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memmove.c
More file actions
49 lines (45 loc) · 1.47 KB
/
ft_memmove.c
File metadata and controls
49 lines (45 loc) · 1.47 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sparth <sparth@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/06 19:38:13 by sparth #+# #+# */
/* Updated: 2023/10/16 19:08:01 by sparth ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
size_t count;
unsigned char *destination;
unsigned char *source;
count = 0;
destination = (unsigned char *) dst;
source = (unsigned char *) src;
if (!dst && !src)
return (NULL);
if (source < destination)
{
while (len--)
destination[len] = source[len];
}
else
{
while (count < len)
{
destination[count] = source[count];
count++;
}
}
return (dst);
}
// int main()
// {
// char dst [] = "whatwhat";
// char src [] = "bhatbhat";
// ft_memmove(dst, src, 9);
// printf("%s\n", dst);
// return (0);
// }