-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strstr.c
More file actions
41 lines (38 loc) · 1.27 KB
/
ft_strstr.c
File metadata and controls
41 lines (38 loc) · 1.27 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
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ppanchen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/23 17:03:48 by ppanchen #+# #+# */
/* Updated: 2016/11/29 14:28:15 by ppanchen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *big, const char *little)
{
int i;
int j;
char *str;
char *to_find;
i = 0;
if (!big || !little)
return (0);
str = (char *)big;
to_find = (char *)little;
while (str[i])
{
j = 0;
while (to_find[j] == str[i + j])
{
if (to_find[j + 1] == 0)
return (str + i);
j++;
}
i++;
}
if (ft_strlen(to_find) == 0)
return (str);
return (0);
}