ft_strrchr
Subject
STRRCHR(3) (simplified)
NAME
strrchr -- locate character in string
SYNOPSIS
char *strrchr(const char *s, int c);
DESCRIPTION
The strrchr() function is identical to strchr(), except it locates the last occurence of c.
RETURN VALUES
The function strrchr() returns a pointer to the located character, or NULL if the character does not appear in the string.Understandable explanation
Hints
char *ft_strrchr(const char *s, int c)
{
/* we can use basically the same code as ft_strchr() but not returning
* the value as soon as we find the character, just setting a variable
* each time, and returning it at the end of the function
*/
/* loop over the whole string */
/* check if current character is equal to the one we have to find */
/* once we looped over the whole string, check again for the character
* in case the character we have to find is '\0'
*/
/* if we didn't find c in the string, return NULL */
}Commented solution
Last updated