libft
Loading...
Searching...
No Matches
ft_strrchr.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strrchr.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2022/10/31 11:30:03 by tspoof #+# #+# */
9/* Updated: 2022/11/15 20:41:31 by tspoof ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15char *ft_strrchr(const char *s, int c)
16{
17 int slen;
18
19 slen = ft_strlen(s);
20 while (slen >= 0)
21 {
22 if (s[slen] == (unsigned char)c)
23 {
24 return ((char *)(s + slen));
25 }
26 slen--;
27 }
28 return (NULL);
29}
char * ft_strrchr(const char *s, int c)
Search a character starting from the end.
Definition ft_strrchr.c:15
size_t ft_strlen(const char *s)
Length of the string.
Definition ft_strlen.c:15