-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
40 lines (37 loc) · 1.33 KB
/
ft_strstr.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
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nekitoss <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/24 18:56:14 by nekitoss #+# #+# */
/* Updated: 2016/11/24 18:56:15 by nekitoss ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *big, const char *s2)
{
size_t b;
size_t l;
size_t max_len;
if (s2[0] != '\0' && s2 != NULL)
{
if (big)
{
max_len = ft_strlen(big) - ft_strlen(s2);
b = 0;
while (big[b] != '\0' && b <= max_len)
{
l = 0;
while (big[b] != '\0' && s2[l] != '\0' && big[b + l] == s2[l])
l++;
if (s2[l] == '\0')
return ((char *)(&big[b]));
b++;
}
}
return (NULL);
}
return ((char *)(big));
}