forked from josanri/Libft_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
36 lines (33 loc) · 1.31 KB
/
ft_strrchr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aalvarez <aalvarez@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/17 00:16:52 by aalvarez #+# #+# */
/* Updated: 2022/08/17 20:09:24 by aalvarez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief finds the last occurence of the char c in the
* string pointed by s.
*
* @param s the string to search.
* @param c the character to search.
* @return char* reference to the first match (or NULL if c
* was not fund on the string).
*/
char *ft_strrchr(const char *s, int c)
{
int len;
len = ft_strlen(s);
while (len >= 0)
{
if (s[len] == (char)c)
return ((char *)s + len);
len--;
}
return (NULL);
}