-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_strsuffix.c
31 lines (29 loc) · 1.25 KB
/
ft_strsuffix.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
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsuffix.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlambert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/04/01 23:19:20 by rlambert #+# #+# */
/* Updated: 2015/04/01 23:19:21 by rlambert ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strsuffix(const char *str, const char *suffix)
{
const char *str_iter;
const char *suffix_iter;
str_iter = str;
suffix_iter = suffix;
while (*str_iter != '\0')
str_iter++;
while (*suffix_iter != '\0')
suffix_iter++;
while (suffix_iter >= suffix && str_iter >= str &&
*str_iter == *suffix_iter)
{
str_iter--;
suffix_iter--;
}
return (suffix_iter < suffix);
}