29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memchr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/08/23 23:21:11 by rzy #+# #+# */
|
|
/* Updated: 2026/08/23 23:21:27 by rzy ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include "libft.h"
|
|
|
|
void *ft_memchr(const void *s, int c, size_t n)
|
|
{
|
|
unsigned char *ptr;
|
|
size_t i;
|
|
|
|
ptr = (unsigned char *)s;
|
|
i = 0;
|
|
while (i < n)
|
|
{
|
|
if (ptr[i] == (unsigned char)c)
|
|
return ((void *)s + i);
|
|
++i;
|
|
}
|
|
return (NULL);
|
|
}
|