14-04-2026
26 lines
1.2 kB
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strnstr.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: mleitao <mleitao@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/03/12 16:57:02 by mleitao #+# #+# */
9/* Updated: 2026/04/14 19:37:14 by mleitao ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15char *ft_strnstr(const char *big, const char *little, size_t len)
16{
17 size_t little_len;
18
19 if (!*little)
20 return ((char *)big);
21 little_len = ft_strlen(little);
22 while (len-- >= little_len && *big)
23 if (!ft_strncmp(big++, little, little_len))
24 return ((char *)(big - 1));
25 return (NULL);
26}