-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
35 lines (32 loc) · 1.14 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: dbrandao <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/04 01:09:09 by dbrandao #+# #+# */
/* Updated: 2022/07/01 21:07:16 by dbrandao ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char *last;
char lc;
lc = '\0';
while (*s)
{
if (*s == (char) c)
{
last = (char *) s;
lc = *last;
}
s++;
}
if (lc)
return (last);
if (*s == (char) c)
return ((char *) s);
return (NULL);
}