minishell
ft_memchr.c File Reference
#include <stddef.h>
#include "ft_mem.h"
Include dependency graph for ft_memchr.c:

Go to the source code of this file.

Functions

void * ft_memchr (const void *s, int c, size_t n)
 

Function Documentation

◆ ft_memchr()

void* ft_memchr ( const void *  s,
int  c,
size_t  n 
)

Definition at line 16 of file ft_memchr.c.

17 {
18  unsigned char *p_s;
19  unsigned char looking_for;
20 
21  if (n == 0)
22  return (NULL);
23  p_s = (unsigned char *)s;
24  looking_for = (unsigned char)c;
25  while (--n > 0 && *p_s != looking_for)
26  p_s++;
27  if (*p_s == looking_for)
28  return (p_s);
29  else
30  return (NULL);
31 }
Here is the caller graph for this function: