29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memchr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/11/29 00:11:39 by apommier #+# #+# */
|
|
/* Updated: 2020/12/12 13:53:45 by apommier ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
void *ft_memchr(const void *s, int c, size_t n)
|
|
{
|
|
unsigned char *str;
|
|
|
|
str = (unsigned char*)s;
|
|
while (n)
|
|
{
|
|
if ((unsigned char)c == *str)
|
|
return (str);
|
|
n--;
|
|
str++;
|
|
}
|
|
return (0);
|
|
}
|