-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
34 lines (30 loc) · 1.39 KB
/
ft_strrchr.c
File metadata and controls
34 lines (30 loc) · 1.39 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fsanz-ex <fsanz-ex@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/26 15:12:18 by fsanz-ex #+# #+# */
/* Updated: 2023/02/14 15:40:39 by fsanz-ex ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*Locates the last occurrence of c (converted to a char) in the string pointed
to by s. The terminating null character is considered to be part of the string;
therefore if c is '\0', the functions locate the terminating '\0'. Returns a
pointer to the located character, or NULL if the character does not appear.*/
char *ft_strrchr(const char *s, int c)
{
int i;
char *st;
i = ft_strlen(s);
st = (char *) s;
while (i >= 0)
{
if (st[i] == (char) c)
return (&st[i]);
i--;
}
return (NULL);
}