You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strrchr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2021/10/18 16:47:21 by narnaud #+# #+# */
|
|
/* Updated: 2021/11/15 09:01:44 by narnaud ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strrchr(const char *s, int c)
|
|
{
|
|
size_t i;
|
|
int found;
|
|
|
|
i = 0;
|
|
found = -1;
|
|
while (s[i])
|
|
{
|
|
if (s[i] == (c % 256))
|
|
found = i;
|
|
i++;
|
|
}
|
|
if (c == '\0')
|
|
return ((char *)(s + i));
|
|
if (found >= 0)
|
|
return ((char *)(s + found));
|
|
return (0);
|
|
}
|
|
|