base c lib without external lib
This commit is contained in:
27
ft_strrchr.c
Normal file
27
ft_strrchr.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strrchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/11/05 17:28:39 by dgaillet #+# #+# */
|
||||
/* Updated: 2025/11/05 17:33:38 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strrchr(const char *s, int c)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (s[i])
|
||||
i++;
|
||||
while (i >= 0)
|
||||
{
|
||||
if (s[i] == c)
|
||||
return ((char *) &s[i]);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user