-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strnstr.c
33 lines (30 loc) · 1.27 KB
/
ft_strnstr.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
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: amacarul <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/10 12:38:50 by amacarul #+# #+# */
/* Updated: 2024/09/23 12:23:56 by amacarul ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t start;
size_t i;
start = 0;
if (little[start] == '\0')
return ((char *)big);
while (big[start] != '\0' && len > start)
{
i = 0;
while (little[i] && (len > start + i) && (big[start + i] == little[i]))
i ++;
if (little[i] == '\0')
return ((char *)(big + start));
start ++;
}
return (NULL);
}