30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memchr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tchivert <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/04/04 16:35:16 by tchivert #+# #+# */
|
|
/* Updated: 2019/09/04 05:13:29 by tchivert ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
void *ft_memchr(const void *s, int c, size_t len)
|
|
{
|
|
unsigned int i;
|
|
unsigned char *ptr;
|
|
|
|
i = 0;
|
|
ptr = (unsigned char *)s;
|
|
while (i < len)
|
|
{
|
|
if (ptr[i] == (unsigned char)c)
|
|
return ((void *)s + i);
|
|
i++;
|
|
}
|
|
return (NULL);
|
|
}
|