-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_strstr.c
37 lines (34 loc) · 1.24 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: rlambert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/04 14:58:25 by rlambert #+# #+# */
/* Updated: 2015/11/09 19:28:56 by roblabla ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
char *ft_strstr(const char *s1, const char *s2)
{
const char *s1_it;
const char *s2_it;
if (*s2 == '\0')
return ((char*)s1);
while (*s1 != '\0')
{
s1_it = s1;
s2_it = s2;
while (*s2_it != '\0' && *s1_it == *s2_it)
{
s1_it++;
s2_it++;
}
if (*s2_it == '\0')
return ((char*)s1);
s1++;
}
return (NULL);
}