-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
30 lines (28 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: meltremb <meltremb@student.42quebec> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/30 13:59:11 by meltremb #+# #+# */
/* Updated: 2022/04/05 13:21:46 by meltremb ### ########.fr */
/* */
/* ************************************************************************** */
/* ___-------------------v there it is (last occurence)
* | str = "The cake is a lie" c = 'a'_______ ____
* |__________________________ | | |
* | |_|____|
* |________________________| */
#include"libft.h"
char *ft_strrchr(const char *s, int c)
{
const char *temp;
temp = s;
while (*s)
s++;
while (s >= temp)
if (*s-- == (char) c)
return ((char *)s + 1);
return (NULL);
}