-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
39 lines (36 loc) · 1.18 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
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tlevaufr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/13 16:49:28 by tlevaufr #+# #+# */
/* Updated: 2017/11/24 01:58:52 by tlevaufr ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int i;
i = 0;
if (c == 0)
{
while (s[i])
i++;
return ((char *)&s[i]);
}
if (c > 0)
{
while (s[i])
i++;
while (i >= 0 && s[i] != c)
i--;
if (i >= 0)
return ((char *)&s[i]);
else
return (NULL);
}
else
return (NULL);
}