minishell
ft_strrchr.c
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* ft_strrchr.c :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: kfujita <kfujita@student.42tokyo.jp> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2022/04/10 14:54:20 by kfujita #+# #+# */
9 /* Updated: 2022/04/11 22:42:36 by kfujita ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #include <stddef.h>
14 
15 char *ft_strrchr(const char *s, int 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 }
char * ft_strrchr(const char *s, int c)
Definition: ft_strrchr.c:15