-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strstr.c
39 lines (36 loc) · 1.28 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
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igarbuz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/13 17:44:33 by igarbuz #+# #+# */
/* Updated: 2018/11/15 23:23:25 by igarbuz ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
char *ft_strstr(const char *haystack, const char *needle)
{
char *myc;
char *tmp;
if (!*needle)
return ((char *)haystack);
while (*haystack)
{
if (*haystack == *needle)
{
myc = (char *)haystack;
tmp = (char *)needle;
while (*myc == *tmp && *myc && *tmp)
{
myc++;
tmp++;
}
if (*tmp == '\0')
return ((char *)haystack);
}
haystack++;
}
return (NULL);
}