-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
32 lines (29 loc) · 1.14 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rdragan <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/04 15:52:31 by rdragan #+# #+# */
/* Updated: 2022/11/10 19:41:12 by rdragan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
Locates the last occurence of c in s.
*/
char *ft_strrchr(const char *s, int c)
{
size_t i;
i = ft_strlen(s);
while (i)
{
if (s[i] == (char)c)
return ((char *)s + i);
i--;
}
if (s[0] == (char)c)
return ((char *)s);
return (NULL);
}