Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_memchr.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_memchr.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: raphalme <raphalme@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/12/29 18:51:00 by raphalme #+# #+# */
9/* Updated: 2026/04/14 10:45:22 by raphalme ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include <stdlib.h>
14
23void *ft_memchr(const void *s, int c, size_t n)
24{
25 const unsigned char *ptr;
26
27 ptr = (const unsigned char *)s;
28 while (n--)
29 {
30 if (*ptr == (unsigned char)c)
31 return ((void *)ptr);
32 ptr++;
33 }
34 return (NULL);
35}
void * ft_memchr(const void *s, int c, size_t n)
Scans a memory area for a byte value.
Definition ft_memchr.c:23