1
0
cub3d/libft/mem/ft_memchr.c

30 lines
1.1 KiB
C
Raw Normal View History

2024-09-10 16:27:06 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}