-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
33 lines (30 loc) · 1.17 KB
/
ft_strrchr.c
File metadata and controls
33 lines (30 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jagarcia <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/11 19:40:35 by jagarcia #+# #+# */
/* Updated: 2017/11/13 18:24:34 by jagarcia ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char *scpy;
char ccpy;
size_t len;
scpy = (char *)s;
len = ft_strlen(scpy);
ccpy = (char)c;
while (len > 0)
{
if (scpy[len] == ccpy)
return (&scpy[len]);
len--;
}
if (scpy[len] == ccpy)
return (&scpy[len]);
return (NULL);
}