-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strnstr.c
More file actions
31 lines (28 loc) · 948 Bytes
/
ft_strnstr.c
File metadata and controls
31 lines (28 loc) · 948 Bytes
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_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dyanar <dyanar@student.42istanbul.com.tr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/04 20:38:52 by dyanar #+# #+# */
/* Updated: 2026/02/04 20:38:52 by dyanar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t len_little;
len_little = ft_strlen(little);
if (len_little == 0)
return ((char *)big);
while (*big && len-- > 0)
{
if (len < len_little - 1)
return (NULL);
if (ft_strncmp(big, little, len_little) == 0)
return ((char *)big);
big++;
}
return (NULL);
}