-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
30 lines (27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gpiccion <gpiccion@student.42wolfsburg. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/18 12:23:40 by gpiccion #+# #+# */
/* Updated: 2021/11/18 12:23:40 by gpiccion ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// Returns a pointer to the last occurrence of the char 'c' in the string 's'.
char *ft_strrchr(const char *str, int c)
{
int i;
char *aux;
i = ft_strlen(str);
aux = (char *) str;
while (i >= 0)
{
if (aux[i] == (char)c)
return (aux + i);
i--;
}
return (NULL);
}