libftx/libft/ft_memchr.c
Camille Chauvet 3256ce67f7 kekw
2022-12-22 17:57:19 +01:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 13:40:09 by cchauvet #+# #+# */
/* Updated: 2022/09/27 13:59:03 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *tab;
size_t i;
unsigned char tofind;
tab = (unsigned char *) s;
tofind = (unsigned char) c;
i = 0;
while (i < n)
{
if (tab[i] == tofind)
return (tab + i);
i++;
}
return (NULL);
}