-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
38 lines (34 loc) · 1.24 KB
/
ft_strrchr.c
File metadata and controls
38 lines (34 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mraineri <mraineri@student.42lisboa.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/18 14:19:40 by mraineri #+# #+# */
/* Updated: 2024/05/22 17:00:59 by mraineri ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int i;
i = ft_strlen((char *)s);
if (!s)
return (NULL);
while (i >= 0)
{
if ((unsigned char)s[i] == (unsigned char)c)
return ((char *)&s[i]);
i--;
}
return (NULL);
}
//int main(void)
//{
// char *s = "tripouille";
// printf(":%s\n",ft_strrchr(s, 'i' + 256));
// return (0);
//}
// =-=
// =-=-Marcelo