-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchr.c
72 lines (55 loc) · 1.71 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: musenov <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 00:08:36 by musenov #+# #+# */
/* Updated: 2022/12/06 13:42:43 by musenov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
int i;
i = 0;
while (*(s + i) != '\0')
{
i++;
}
while (i >= 0)
{
if ((char)c == *(s + i))
return ((char *)s + i);
i--;
}
return (0);
}
/*
ft_strrchr:
PARAMETERS
-/-
RETURN VALUE
The functions strchr() and strrchr() return a pointer to the located
character, or NULL if the character does not appear in the string.
DESCRIPTION
The strchr() function locates the first 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'.
The strrchr() function is identical to strchr(), except it locates the
last occurrence of c.
QUESTIONS
-/-
ANSWER
-/-
COMPARE
-/-
ALTERNATIVE SOLUTION
-/-
EXPLANATION
-/-
REMARK
-/-
*/