-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
32 lines (28 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zkharbac <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/22 15:08:14 by zkharbac #+# #+# */
/* Updated: 2024/11/29 10:44:02 by zkharbac ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int i;
char *last_occurrence;
i = 0;
last_occurrence = NULL;
while (s[i] != '\0')
{
if ((unsigned char)s[i] == (unsigned char)c)
last_occurrence = (char *)&s[i];
i++;
}
if ((char) c == '\0')
return ((char *)&s[i]);
return (last_occurrence);
}