-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
35 lines (32 loc) · 1.12 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: hnabil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/17 17:31:56 by hnabil #+# #+# */
/* Updated: 2019/10/25 19:37:38 by hnabil ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
int i;
int j;
char *s;
s = (char *)str;
i = 0;
j = 0;
while (s[i])
{
if (s[i] == c)
j = i + 1;
i++;
}
if (!c)
return (&s[i]);
if (j)
return (s + j - 1);
return (NULL);
}