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

Go to the source code of this file.

Functions

char * ft_strrchr (const char *s, int c)
 

Function Documentation

◆ ft_strrchr()

char* ft_strrchr ( const char *  s,
int  c 
)

Definition at line 15 of file ft_strrchr.c.

16 {
17  const char *p_c_found;
18 
19  p_c_found = NULL;
20  while (*s != '\0')
21  {
22  if (*s == (char)c)
23  p_c_found = s;
24  s++;
25  }
26  if (p_c_found != NULL)
27  return ((char *)p_c_found);
28  else if (c == '\0')
29  return ((char *)s);
30  else
31  return (NULL);
32 }