-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
38 lines (34 loc) · 1.23 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
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/12 00:12:22 by kakiba #+# #+# */
/* Updated: 2022/07/24 21:34:00 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
size_t i;
size_t len;
char *ptr;
i = 0;
len = ft_strlen(s);
ptr = (char *)s;
while (len >= i)
{
if (ptr[len - i] == (char)c)
return (&ptr[len - i]);
i++;
}
return (NULL);
}
//
//int main()
//{
// printf("%s\n", strrchr("abc", 'b' + 256));
// printf("%s\n", ft_strrchr("abc", 'b' + 256));
//}