-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
37 lines (33 loc) · 1.22 KB
/
ft_strrchr.c
File metadata and controls
37 lines (33 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: csilva-s <csilva-s@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:04:00 by csilva-s #+# #+# */
/* Updated: 2025/08/15 19:09:13 by csilva-s ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_strrchr(const char *s, int c);
char *ft_strrchr(const char *s, int c)
{
short i;
char cc;
char *result;
i = 0;
cc = (char )c;
result = NULL;
if (!cc)
return ((char *)s + ft_strlen(s));
while (s[i])
{
if (s[i] == cc)
result = (char *)&s[i];
i++;
}
if (c == 0)
result = (char *)&s[i];
return (result);
}