-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
35 lines (32 loc) · 1.2 KB
/
ft_strrchr.c
File metadata and controls
35 lines (32 loc) · 1.2 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmoufakk <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/10 17:59:49 by mmoufakk #+# #+# */
/* Updated: 2018/10/20 14:54:56 by mmoufakk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int i;
char test;
char *stest;
i = ft_strlen(s) - 1;
test = (char)c;
stest = (char *)s;
if (stest[i + 1] == test)
{
return (stest + (i + 1));
}
while (stest[i] != '\0' && i >= 0)
{
if (stest[i] == test)
return (stest + i);
i--;
}
return (NULL);
}