-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
38 lines (34 loc) · 1.36 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
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rruiz-sa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/22 16:40:42 by rruiz-sa #+# #+# */
/* Updated: 2022/10/13 21:15:39 by rruiz-sa ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *str, int c)
{
int i;
i = ft_strlen(str);
while (i >= 0)
{
if (str[i] == (char)c)
return ((char *)&str[i]);
i--;
}
return (0);
}
/*
1- Get the len of the str
2- Iterate while the len >= 0
3- Each iteration
-Check if str are equal to the character passed by the function(c)
-# If its return the rest of te str
4- Outside the iteration return (0)
[Description ft_strlen]
1- Iterate the string, and return the counter(i)
*/