mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 19:36:50 +01:00
34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strrchr.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */
|
||
|
/* Updated: 2024/02/04 14:48:34 by adjoly ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "../libft.h"
|
||
|
|
||
|
char *ft_strrchr(const char *s, int c)
|
||
|
{
|
||
|
size_t i;
|
||
|
size_t len_s;
|
||
|
|
||
|
len_s = ft_strlen(s);
|
||
|
i = len_s;
|
||
|
if (c == 0)
|
||
|
return (&((char *)s)[len_s]);
|
||
|
while (i > 0)
|
||
|
{
|
||
|
if (s[i] == (char)c)
|
||
|
return (&((char *)s)[i]);
|
||
|
i--;
|
||
|
}
|
||
|
if (s[0] == (char)c)
|
||
|
return (&((char *)s)[0]);
|
||
|
return (NULL);
|
||
|
}
|