-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
35 lines (32 loc) · 1.16 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
28
29
30
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hshawand <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 14:38:34 by hshawand #+# #+# */
/* Updated: 2019/04/15 12:06:39 by hshawand ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
char *ft_strrchr(const char *str, int c)
{
size_t count;
count = 0;
while (*str != '\0')
{
str = str + 1;
count++;
}
while (count > 0)
{
if (*str == c)
return ((char *)str);
str = str - 1;
count--;
}
if (*str == c)
return ((char *)str);
return (0);
}