-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathft_strrchr.c
More file actions
31 lines (28 loc) · 1.13 KB
/
ft_strrchr.c
File metadata and controls
31 lines (28 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strrchr.c :+: :+: */
/* +:+ */
/* By: ksmorozo <ksmorozo@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/10/30 18:01:12 by ksmorozo #+# #+# */
/* Updated: 2021/07/07 12:19:36 by ksmorozo ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int ch)
{
int len;
char *last_pos;
len = ft_strlen(str);
while (len >= 0)
{
if (str[len] == (unsigned char)ch)
{
last_pos = (char *)&str[len];
return (last_pos);
}
len--;
}
return (NULL);
}