-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
34 lines (31 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mle-roy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/11/21 16:08:05 by mle-roy #+# #+# */
/* Updated: 2015/01/31 21:18:43 by mle-roy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *s1, const void *s2, int c, size_t n)
{
size_t i;
char *c1;
char *c2;
i = 0;
c1 = (char *)s1;
c2 = (char *)s2;
while (i < n)
{
*c1 = *c2;
if (c == *c2)
return ((void *)++c1);
c1++;
c2++;
i++;
}
return (NULL);
}