-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
35 lines (32 loc) · 1.17 KB
/
ft_memccpy.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oel-yous <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/10 15:05:47 by oel-yous #+# #+# */
/* Updated: 2019/10/18 00:36:17 by oel-yous ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
char *str1;
const char *str2;
size_t i;
i = 0;
str1 = dst;
str2 = src;
while (i < n)
{
if (str2[i] == c)
{
str1[i] = str2[i];
return (&str1[i]);
}
str1[i] = str2[i];
i++;
}
return (NULL);
}