-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strnstr.c
More file actions
36 lines (33 loc) · 1.26 KB
/
Copy pathft_strnstr.c
File metadata and controls
36 lines (33 loc) · 1.26 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
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ebarbash <ebarbash@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/09 21:02:51 by ebarbash #+# #+# */
/* Updated: 2024/10/26 12:34:25 by ebarbash ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
size_t start;
i = 0;
start = 0;
if (!*little)
return ((char *)big);
while (big[start] != '\0' && start < len)
{
i = 0;
while (big[start + i] == little[i] && (start + i) < len)
{
if (little[i + 1] == '\0')
return ((char *)&big[start]);
i++;
}
start++;
}
return (0);
}