-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
27 lines (24 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agarijo- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/30 18:59:53 by agarijo- #+# #+# */
/* Updated: 2022/10/01 16:31:24 by agarijo- ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int count;
count = ft_strlen(s);
if (c == '\0')
return ((char *)(s + count));
while ((*(s + count) != (char) c) && count > 0)
count --;
if ((*(s + count) != (char) c))
return (NULL);
return ((char *)s + count);
}