-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
61 lines (56 loc) · 1.48 KB
/
ft_memmove.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sde-silv <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/22 13:58:56 by sde-silv #+# #+# */
/* Updated: 2023/06/12 14:39:51 by sde-silv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
#include <string.h>
*/
void *ft_memmove(void *dest, const void *src, size_t n)
{
char *char_s;
char *char_d;
size_t i;
i = 0;
if (!dest && !src)
return (NULL);
char_s = (char *)src;
char_d = (char *)dest;
while (i < n)
{
if (dest < src)
{
char_d[i] = char_s[i];
i ++;
}
else
{
char_d[n - 1] = char_s[n - 1];
n --;
}
}
return (dest);
}
/*
int main(void)
{
char dest[12];
char *src = "Hello World!";
char *rtn;
int n;
n = 5;
write (1,src, 12);
write(1, "\n", 1);
rtn = memmove(dest, src, n);
write(1,rtn, n);
write (1, "\n", 1);
return (0);
}
*/