-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_memmove.c
40 lines (37 loc) · 1.28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dzui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/21 16:28:42 by dzui #+# #+# */
/* Updated: 2016/11/25 18:14:39 by dzui ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dest, const void *src, size_t n)
{
unsigned long i;
const char *temp_src;
char *temp_dest;
char *buff;
i = 0;
temp_dest = dest;
temp_src = src;
buff = (char *)malloc(sizeof(char) * n + 1);
while (i < n)
{
buff[i] = temp_src[i];
i++;
}
buff[i] = '\0';
i = 0;
while (i < n)
{
temp_dest[i] = buff[i];
i++;
}
free(buff);
return (temp_dest);
}