-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
32 lines (30 loc) · 1.21 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: dlom <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/22 22:58:42 by dlom #+# #+# */
/* Updated: 2023/01/22 22:58:42 by dlom ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
RETURNs a pointer to the last occurence of a specific character in the string.
if not found, return NULL
*/
char *ft_strrchr(const char *str, int c)
{
int i;
i = ft_strlen((char *)str);
while (i >= 0)
{
if (str[i] == c)
{
return ((char *)(str + i));
}
i--;
}
return (0);
}