tgrekov-libft
HIVE libft Oct 2023
Loading...
Searching...
No Matches
ft_memmove.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memmove.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/10/23 15:24:02 by tgrekov #+# #+# */
9
/* Updated: 2023/11/04 22:47:05 by tgrekov ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
20
#include "
libft.h
"
21
34
void
*
ft_memmove
(
void
*dst,
const
void
*src,
size_t
len)
35
{
36
size_t
i;
37
char
dir;
38
39
if
(src != dst)
40
{
41
i = 0;
42
dir = 1;
43
if
(dst > src)
44
{
45
i = len - 1;
46
dir = -1;
47
}
48
while
(len--)
49
{
50
((
unsigned
char
*) dst)[i] = ((
unsigned
char
*) src)[i];
51
i += dir;
52
}
53
}
54
return
(dst);
55
}
ft_memmove
void * ft_memmove(void *dst, const void *src, size_t len)
Copies len bytes from byte string src to byte string dst non-destructively.
Definition
ft_memmove.c:34
libft.h
ft_memmove.c