-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
25 lines (23 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmoska <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/18 11:48:00 by tmoska #+# #+# */
/* Updated: 2016/11/18 11:55:35 by tmoska ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
if (n != 0)
{
*(unsigned char *)dst = *(unsigned char *)src;
if (*(unsigned char *)src == (unsigned char)c)
return (dst + 1);
return (ft_memccpy(dst + 1, src + 1, c, --n));
}
return (NULL);
}