ft_memccpy.c 1.2 KB

12345678910111213141516171819202122232425
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_memccpy.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/21 15:29:02 by mazimi #+# #+# */
  9. /* Updated: 2014/12/02 15:55:41 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. void *ft_memccpy(void *dst, const void *src, int c, size_t n)
  14. {
  15. if (n != 0)
  16. {
  17. *(unsigned char *)dst = *(unsigned char *)src;
  18. if (*(unsigned char *)src == (unsigned char)c)
  19. return (dst + 1);
  20. return (ft_memccpy(dst + 1, src + 1, c, --n));
  21. }
  22. return (NULL);
  23. }