-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memmove.c
executable file
·38 lines (35 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aemebiku <aemebiku@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/06/26 15:36:57 by aemebiku #+# #+# */
/* Updated: 2014/06/26 15:36:58 by aemebiku ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
void *ft_memmove(void *s1, const void *s2, size_t n)
{
char *str1;
char *str2;
char *temp;
size_t i;
i = 0;
str1 = (char *)s1;
str2 = (char *)s2;
if (str1 == NULL || str2 == NULL)
return (0);
temp = (char *)malloc(sizeof(*temp) * ft_strlen(str2));
if (temp == NULL)
return (NULL);
temp = ft_strcpy(temp, str2);
while (i < n)
{
str1[i] = temp[i];
i++;
}
return (str1);
}