-
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.16 KB
/
ft_strrchr.c
File metadata and controls
33 lines (30 loc) · 1.16 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: falarm <falarm@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/11 20:46:00 by falarm #+# #+# */
/* Updated: 2021/10/12 19:44:02 by falarm ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char ch;
char *found;
char *tmp;
ch = c;
found = NULL;
if (ch == '\0')
return (ft_strchr(s, c));
tmp = ft_strchr(s, c);
while (tmp != NULL)
{
found = tmp;
s = tmp + 1;
tmp = ft_strchr(s, c);
}
return (found);
}