/ src / ft_str_endswith.c
ft_str_endswith.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   ft_str_endswith.c                                  :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: ll-hotel <ll-hotel@student.42lyon.fr>      +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2024/07/26 14:43:29 by ll-hotel          #+#    #+#             */
 9  /*   Updated: 2024/07/26 14:52:27 by ll-hotel         ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "libft.h"
14  
15  int	ft_str_endswith(const char *s1, const char *s2)
16  {
17  	const int	len1 = ft_strlen(s1);
18  	const int	len2 = ft_strlen(s2);
19  
20  	if (len2 > len1)
21  		return (0);
22  	return (ft_strncmp(s1 + len1 - len2, s2, len2) == 0);
23  }