/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memccpy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:06:41 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:06:41 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include void *ft_memccpy(void *dst, const void *src, int c, size_t n) { unsigned char *dst_ptr; const unsigned char *src_ptr; dst_ptr = (unsigned char*)dst; src_ptr = (unsigned char*)src; if (!*dst_ptr && !*src_ptr && n) return (NULL); if (n) { while (n) { if ((*dst_ptr++ = *src_ptr++) == (unsigned char)c) return (dst_ptr); n--; } } return (NULL); }