-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
31 lines (28 loc) · 1.11 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: moel-asr <moel-asr@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 22:10:42 by moel-asr #+# #+# */
/* Updated: 2022/10/18 16:12:37 by moel-asr ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
int i;
char *s;
unsigned char k;
i = ft_strlen(str);
s = (char *)str;
k = (unsigned char)c;
while (i >= 0)
{
if (s[i] == k)
return (s + i);
i--;
}
return (0);
}