-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
34 lines (31 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strrchr.c :+: :+: */
/* +:+ */
/* By: cherrewi <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/10/19 15:13:31 by cherrewi #+# #+# */
/* Updated: 2022/10/19 15:17:00 by cherrewi ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
finds first char in string, searching right to left
*/
char *ft_strrchr(const char *s, int c)
{
const char *str_i;
str_i = s;
while (*str_i)
{
str_i++;
}
while (str_i >= s)
{
if (*str_i == (char)c)
return ((char *)str_i);
str_i--;
}
return (NULL);
}