Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_strrchr.c File Reference
+ Include dependency graph for ft_strrchr.c:

Go to the source code of this file.

Functions

char * ft_strrchr (const char *s, int c)
 Finds the last occurrence of a character in a string.
 

Function Documentation

◆ ft_strrchr()

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

Finds the last occurrence of a character in a string.

Parameters
sInput string.
cCharacter to search for.
Returns
Pointer to the last match, or NULL if not found.

Definition at line 22 of file ft_strrchr.c.

23{
24 int i;
25
26 i = ft_strlen(s);
27 if ((char)c == '\0')
28 return ((char *)&s[i]);
29 while (i >= 0)
30 {
31 if (s[i] == (char)c)
32 return ((char *)&s[i]);
33 i--;
34 }
35 return (NULL);
36}
size_t ft_strlen(const char *str)
Returns the length of a null-terminated string.
Definition ft_strlen.c:21

References ft_strlen().

+ Here is the call graph for this function: