-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
38 lines (35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ewilliam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 09:09:56 by ewilliam #+# #+# */
/* Updated: 2016/12/08 14:56:42 by ewilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int is_str_in_str(const char *s, const char *find)
{
if (!*find)
return (1);
if (*s && *find)
{
if (*s == *find)
return (is_str_in_str(++s, ++find));
}
return (0);
}
char *ft_strstr(const char *big, const char *little)
{
if (!*little)
return ((char*)big);
while (*big)
{
if (is_str_in_str(big, little))
return ((char*)big);
big++;
}
return (NULL);
}