-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
26 lines (23 loc) · 1.06 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yxu <yxu@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/15 13:41:57 by yxu #+# #+# */
/* Updated: 2023/09/26 15:22:43 by yxu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int i;
i = 0;
while (s[i])
i++;
while (i >= 0)
if (s[i--] == (unsigned char)c)
return ((char *)&s[i + 1]);
return (NULL);
}