-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strnstr.c
36 lines (33 loc) · 1.21 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
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mosborne <mosborne@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/09/27 17:16:18 by mosborne #+# #+# */
/* Updated: 2017/09/28 15:38:51 by mosborne ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
size_t x;
i = 0;
if (!*little)
return ((char *)big);
while (big[i])
{
x = 0;
while (big[i] == little[x] && big[i] && i < len)
{
i++;
x++;
}
if (!little[x])
return ((char *)&big[i - x]);
i = (i - x) + 1;
}
return (0);
}