-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
36 lines (33 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kyork <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/15 09:16:29 by kyork #+# #+# */
/* Updated: 2016/09/23 20:14:59 by kyork ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *str, const char *to_find)
{
const char *s;
const char *f;
if (!*to_find)
return ((char*)str);
while (*str)
{
s = str;
f = to_find;
while (*s && *f)
if (*s++ != *f)
break ;
else
f++;
if (*f == 0)
return ((char*)str);
str++;
}
return (0);
}