33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strrchr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2020/10/29 13:10:04 by pbonilla #+# #+# */
|
|
/* Updated: 2020/11/19 15:09:23 by pbonilla ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strrchr(const char *s, int c)
|
|
{
|
|
int i;
|
|
int j;
|
|
|
|
i = -1;
|
|
j = -1;
|
|
while (s[++i])
|
|
{
|
|
if (s[i] == (char)c)
|
|
j = i;
|
|
}
|
|
if (s[i] == (char)c)
|
|
return ((char *)&s[i]);
|
|
if (j == -1)
|
|
return (NULL);
|
|
return ((char *)&s[j]);
|
|
}
|