-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strstr.c
More file actions
36 lines (33 loc) · 1.25 KB
/
ft_strstr.c
File metadata and controls
36 lines (33 loc) · 1.25 KB
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: pruthann <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/26 14:36:40 by pruthann #+# #+# */
/* Updated: 2020/07/26 20:36:22 by pruthann ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
char *ft_strnstr(const char *haystack, const char *needle, size_t len)
{
char *temp_str;
char *temp_to_find;
if (!(*to_find))
return (str);
temp_to_find = to_find;
while (*str)
{
temp_str = str;
while (*(str++) == *(to_find++))
{
if (!(*to_find))
return (temp_str);
if (!(*str))
return (0);
}
to_find = temp_to_find;
}
return (0);
}