-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
28 lines (25 loc) · 1.1 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rtiutiun <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/04/10 23:49:52 by rtiutiun #+# #+# */
/* Updated: 2017/09/21 23:50:23 by rtiutiun ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int last;
int i;
i = -1;
last = -1;
while (s[++i])
if (s[i] == (unsigned char)c)
last = i;
if (c == 0)
last = i;
return (last != -1 ? (char *)(s + last) : 0);
}