-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
40 lines (34 loc) · 1.29 KB
/
ft_strrchr.c
File metadata and controls
40 lines (34 loc) · 1.29 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
32
33
34
35
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ibravo-m <ibravo-m@student.42lisboa.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/23 13:26:09 by ibravo-m #+# #+# */
/* Updated: 2024/05/02 15:22:13 by ibravo-m ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// finds the first occurence of c, starting in the end of the string.
char *ft_strrchr(const char *str, int c)
{
int i;
i = (int)ft_strlen(str);
while (i >= 0)
{
if (str[i] == (char)c)
{
return ((char *)&str[i]);
}
i--;
}
return (0);
}
// int main(void)
// {
// const char str[] = "bom dmia";
// int ch = 0;
// printf("%s\n", ft_strrchr(str, ch));
// printf("%s\n", strrchr(str, ch));
// }