-
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) · 1.21 KB
/
ft_strnstr.c
File metadata and controls
31 lines (28 loc) · 1.21 KB
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: dbrandao <dbrandao@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/06 04:48:39 by dbrandao #+# #+# */
/* Updated: 2022/07/01 21:07:09 by dbrandao ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
size_t little_len;
i = 0;
little_len = ft_strlen(little);
if (!*little)
return ((char *) big);
while (i + little_len <= len && big[i])
{
if (!ft_strncmp(&big[i], little, little_len))
return ((char *)(&big[i]));
i++;
}
return (NULL);
}