-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
executable file
·27 lines (24 loc) · 1.08 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mberger <mberger@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/10 18:13:02 by mberger #+# #+# */
/* Updated: 2014/11/11 09:56:46 by mberger ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
size_t i;
char k;
i = ft_strlen(s);
k = (char)c;
while ((i != 0) && s[i] != k)
i--;
if (s[i] == k)
return ((char*)&s[i]);
return (NULL);
}