33 lines
1.2 KiB
C
33 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memccpy.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/10/27 19:40:08 by pbonilla #+# #+# */
|
|
/* Updated: 2021/01/29 12:00:11 by pbonilla ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
|
|
{
|
|
unsigned char *buff;
|
|
unsigned char *buff2;
|
|
unsigned int i;
|
|
|
|
buff = (unsigned char *)dest;
|
|
buff2 = (unsigned char *)src;
|
|
i = 0;
|
|
while (i < n)
|
|
{
|
|
buff[i] = buff2[i];
|
|
if (buff2[i] == (unsigned char)c)
|
|
return ((void *)(dest + i + 1));
|
|
++i;
|
|
}
|
|
return (NULL);
|
|
}
|