Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
libft/ft_memchr.c

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
/* Updated: 2023/11/08 14:52:06 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#define BUFFER_SIZE 10
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
i = 0;
while (((char *)s)[i] && i < n)
{
if (((char *)s)[i] == (char)c)
return (((char *)s + i));
i++;
}
if (c == 0)
return (((char *)s) + i);
return (NULL);
}