-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
32 lines (29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkwayiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/22 14:17:48 by jkwayiba #+# #+# */
/* Updated: 2019/06/17 15:25:02 by jkwayiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
unsigned char *s2;
unsigned char *d2;
s2 = (unsigned char *)src;
d2 = (unsigned char *)dest;
while (n != 0)
{
*d2 = *s2;
if (*s2 == (unsigned char)c)
return (d2 + 1);
d2++;
s2++;
n--;
}
return (NULL);
}