-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrchr.c
35 lines (32 loc) · 1.2 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
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tedison <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/01 17:23:56 by tedison #+# #+# */
/* Updated: 2021/04/03 12:15:55 by tedison ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strrchr(const char *s, int c)
{
char to_search;
int index;
char *to_return;
to_return = NULL;
index = 0;
to_search = c;
while (s[index])
{
if (s[index] == to_search)
{
to_return = (char *)&s[index];
}
index++;
}
if (c == '\0')
to_return = (char *)&s[index];
return (to_return);
}