ft_memchr.c
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* ft_memchr.c :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: ll-hotel <ll-hotel@student.42lyon.fr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/11/07 15:41:41 by ll-hotel #+# #+# */ 9 /* Updated: 2023/11/09 13:23:36 by ll-hotel ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include <stddef.h> 14 15 void *ft_memchr(const void *s, int c, size_t n) 16 { 17 unsigned char *p; 18 19 p = (unsigned char *)s; 20 while (n-- && *p != (unsigned char)c) 21 p++; 22 if (n + 1) 23 return (p); 24 return (0); 25 }