-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
35 lines (32 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
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: knzeng-e <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/21 05:03:43 by knzeng-e #+# #+# */
/* Updated: 2016/03/29 16:15:32 by knzeng-e ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char *str;
int i;
int j;
str = (char *)s;
i = 0;
j = -1;
while (str[i])
{
if (str[i] == c)
j = i;
i++;
}
if (str[i] == c)
j = i;
if (j >= 0)
return (str + j);
return (NULL);
}