-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
33 lines (31 loc) · 1.09 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strrchr.c :+: :+: */
/* +:+ */
/* By: rvan-mee <rvan-mee@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2022/03/05 13:13:08 by rvan-mee #+# #+# */
/* Updated: 2022/03/05 13:13:09 by rvan-mee ######## odam.nl */
/* */
/* ************************************************************************** */
char *ft_strrchr(const char *s, int c)
{
int i;
int j;
char a;
a = c;
i = 0;
j = -1;
while (s[i])
{
if (s[i] == a)
j = i;
i++;
}
if (s[i] == a)
j = i;
if (j != -1)
return ((char *) &s[j]);
return (0);
}