Files
libft/ft_memchr.c
Angel Ortigosa Perez c87ab67280 Libft aortigos
2025-11-15 09:18:35 +01:00

30 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/22 19:00:54 by aortigos #+# #+# */
/* Updated: 2023/10/26 07:41:42 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
if (((const unsigned char *)s)[i] == (unsigned char)c)
{
return ((void *)&((const unsigned char *)s)[i]);
}
i++;
}
return (NULL);
}