-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
30 lines (27 loc) · 1.07 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: mesafi <mesafi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/01 22:58:36 by mesafi #+# #+# */
/* Updated: 2020/01/20 13:31:42 by mesafi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
int n;
char *p;
n = ft_strlen(str);
p = (char *)str + n;
while (n >= 0)
{
if (*p == c)
return (p);
p--;
n--;
}
return (0);
}