-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
28 lines (25 loc) · 1.09 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hwong <hwong@student.42kl.edu.my> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 12:36:45 by hwong #+# #+# */
/* Updated: 2022/10/07 12:07:59 by hwong ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
size_t i;
char *temp;
i = 0;
temp = (char *)str;
while (*(temp++))
i++;
while (i-- > 0)
if (*(temp--) == c)
return (temp);
return (NULL);
}