-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
50 lines (45 loc) · 1.36 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmattera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 19:56:30 by nmattera #+# #+# */
/* Updated: 2022/05/16 10:30:53 by nmattera ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
size_t i;
char *nsrc;
char *ndest;
nsrc = (char *)src;
ndest = (char *)dest;
if (dest > src)
{
while (n)
{
ndest[n - 1] = nsrc[n - 1];
n--;
}
}
else
{
i = -1;
while (++i < n)
ndest[i] = nsrc[i];
}
return (dest);
}
/*
#include<string.h>
#include<stdio.h>
int main()
{
char csrc[100] = "Geeksfor";
ft_memmove(csrc+5, csrc, strlen(csrc)+1);
printf("%s", csrc);
return 0;
}*/