-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strrchind.c
executable file
·28 lines (25 loc) · 1.1 KB
/
ft_strrchind.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchind.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <tseguier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/14 03:22:51 by tseguier #+# #+# */
/* Updated: 2014/03/27 18:40:34 by jcoignet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
size_t ft_strrchind(const char *str, char c)
{
size_t i;
if (!str)
return (-2);
i = ft_strlen(str);
if (i == 0)
return (-1);
while (*(str + i) != c && i != 0)
--i;
return (i);
}