-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_endswith.c
25 lines (22 loc) · 1.18 KB
/
ft_endswith.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_endswith.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tairribe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/17 21:40:01 by tairribe #+# #+# */
/* Updated: 2024/03/17 22:31:59 by tairribe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_bool ft_endswith(const char *str, const char *suffix) {
size_t suffix_len;
size_t str_len;
suffix_len = ft_strlen(suffix);
str_len = ft_strlen(str);
if (suffix_len > ft_strlen(str)){
return (false);
}
return (ft_strncmp(&str[str_len - suffix_len], suffix, suffix_len) == 0);
}