You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
1.1 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emartine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/07 19:12:29 by emartine #+# #+# */
/* Updated: 2017/11/07 19:12:30 by emartine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *cs;
unsigned char cc;
cs = (unsigned char *)s;
cc = (unsigned char)c;
while (n--)
if (*(cs++) == (unsigned char)c)
return (cs - 1);
return (NULL);
}