-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
32 lines (30 loc) · 1.13 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: oakoudad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/10 19:19:00 by oakoudad #+# #+# */
/* Updated: 2021/11/12 13:49:54 by oakoudad ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strrchr(const char *s, int c)
{
int i;
int tmp;
i = 0;
tmp = 0;
while (1)
{
if (s[i] == (unsigned char)c)
tmp = i;
if (s[i] == '\0')
break ;
i++;
}
s += tmp;
if (s[0] == (unsigned char)c)
return ((char *)s);
return (0);
}