32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_memchr.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/09/27 13:40:09 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/09/27 13:59:03 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
void *ft_memchr(const void *s, int c, size_t n)
|
||
|
{
|
||
|
unsigned char *tab;
|
||
|
size_t i;
|
||
|
unsigned char tofind;
|
||
|
|
||
|
tab = (unsigned char *) s;
|
||
|
tofind = (unsigned char) c;
|
||
|
i = 0;
|
||
|
while (i < n)
|
||
|
{
|
||
|
if (tab[i] == tofind)
|
||
|
return (tab + i);
|
||
|
i++;
|
||
|
}
|
||
|
return (NULL);
|
||
|
}
|