30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_memchr.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2023/10/31 14:41:18 by madumerg #+# #+# */
|
||
|
/* Updated: 2023/11/09 16:24:27 by madumerg ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
void *ft_memchr(const void *s, int c, size_t n)
|
||
|
{
|
||
|
size_t i;
|
||
|
|
||
|
i = 0;
|
||
|
if (!s)
|
||
|
return (0);
|
||
|
while (i < n)
|
||
|
{
|
||
|
if (*(unsigned char *)(s + i) == (unsigned char)c)
|
||
|
return ((void *)(s + i));
|
||
|
i++;
|
||
|
}
|
||
|
return (0);
|
||
|
}
|