ft_printf/libft/ft_memchr.c
2024-10-15 12:43:54 +02:00

25 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: o_ :::::: ::: */
/* ft_memchr.c :+: / :+::+: :+: */
/* +:+ > +:++:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
/* +#+ +#+#+ +#++#+ +#+ \o/ */
/* Created: 2024/10/10 17:00:22 by whaffman #+#+# #+#+# #+# #+# | */
/* Updated: 2024/10/10 17:00:22 by whaffman ### ### ### ### / \ */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
while (0 < n--)
{
if (*(unsigned char *)s == (unsigned char) c)
return ((void *) s);
s++;
}
return (NULL);
}