libft/ft_memchr.c
2023-12-12 17:30:46 +01:00

28 lines
1.1 KiB
C
Executable File

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/10 13:42:10 by fgras-ca #+# #+# */
/* Updated: 2023/02/14 13:03:28 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
if (((unsigned char *)s)[i] == (unsigned char)c)
return ((void *)(s + i));
i++;
}
return (0);
}