woody-woodpacker/ft_printf/libft/ft_memchr.c

30 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/29 12:11:59 by pbonilla #+# #+# */
/* Updated: 2020/11/20 23:33:24 by pbonilla ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *buff;
unsigned int i;
buff = (unsigned char *)s;
i = 0;
while (i != n)
{
if (buff[i] == (unsigned char)c)
return ((void *)&buff[i]);
++i;
}
return (NULL);
}