-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
32 lines (29 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: solariscode <solariscode@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/24 06:03:37 by melkholy #+# #+# */
/* Updated: 2022/02/13 14:54:02 by solariscode ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
char *found;
int count;
count = 0;
found = NULL;
while (str[count])
{
if (str[count] == (unsigned char)c)
found = (char *)str + count;
count ++;
}
if ((unsigned char)c == '\0')
return ((char *)str + count);
else
return (found);
}