-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strrchr.c
executable file
·31 lines (28 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rel-fila <rel-fila@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/16 13:38:33 by rel-fila #+# #+# */
/* Updated: 2022/10/18 22:27:13 by rel-fila ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
int len;
char *sr;
sr = (char *)str;
len = ft_strlen(str);
if (c == '\0')
return (sr + len);
while (len >= 0)
{
if (sr[len] == (char)c)
return (sr + len);
len--;
}
return (0);
}