-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
30 lines (27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: johnavar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/03 07:44:03 by johnavar #+# #+# */
/* Updated: 2024/02/05 21:41:30 by sebasnadu ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../include/libft.h"
char *ft_strrchr(const char *s, int c)
{
char *tmp;
if (s == NULL)
return (NULL);
tmp = (char *)s + ft_strlen(s) + 1;
while (--tmp >= s)
{
if (*tmp == (char)c)
return (tmp);
if (tmp == s)
break ;
}
return (NULL);
}