-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathft_strstr.c
42 lines (39 loc) · 1.27 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
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ggane <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/12 20:09:43 by ggane #+# #+# */
/* Updated: 2016/10/05 20:24:38 by ggane ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *big, const char *little)
{
int i;
int j;
char *pt;
i = 0;
pt = 0;
if (little[i] == '\0')
return ((char *)big);
while (big[i] != '\0')
{
if (big[i] == little[0])
{
pt = (char *)big + i;
j = 0;
while (big[i + j] == little[j])
{
if (little[j + 1] == '\0')
return (pt);
j++;
}
pt = 0;
}
i++;
}
return (0);
}