Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_strrchr.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strrchr.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: raphalme <raphalme@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/12/29 18:48:00 by raphalme #+# #+# */
9/* Updated: 2026/04/14 10:45:22 by raphalme ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "../includes/libft.h"
14
22char *ft_strrchr(const char *s, int 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}
char * ft_strrchr(const char *s, int c)
Finds the last occurrence of a character in a string.
Definition ft_strrchr.c:22
size_t ft_strlen(const char *str)
Returns the length of a null-terminated string.
Definition ft_strlen.c:21