-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
37 lines (34 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lubaujar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/08 17:13:18 by lubaujar #+# #+# */
/* Updated: 2014/11/08 18:02:45 by lubaujar ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(char const *s1, char const *s2)
{
int i;
int j;
int len;
i = 0;
len = ft_strlen(s2);
if (len == 0)
return ((char *)s1);
while (s1[i])
{
j = 0;
while (s2[j] == s1[i + j])
{
if (j == len - 1)
return ((char *)s1 + i);
j++;
}
i++;
}
return (0);
}