-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strrchr.c
More file actions
44 lines (39 loc) · 1.22 KB
/
ft_strrchr.c
File metadata and controls
44 lines (39 loc) · 1.22 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
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: moabed <moabed@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/07 14:31:54 by moabed #+# #+# */
/* Updated: 2025/08/17 17:14:04 by moabed ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char *p;
p = (char *)s;
while (*s)
s++;
while (s >= p)
{
if (*s == (char)c)
{
return ((char *)s);
}
else
s--;
}
return (NULL);
}
/*
#include <stdio.h>
int main(void)
{
char *p;
char x[] ="ahmad";
p = ft_strrchr(x,'a');
printf("%c %c %c",p[0], p[1],p[2]);
}
*/