-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strstr.c
More file actions
executable file
·40 lines (37 loc) · 1.25 KB
/
ft_strstr.c
File metadata and controls
executable file
·40 lines (37 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
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vnakonec <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/24 13:16:49 by vnakonec #+# #+# */
/* Updated: 2016/11/30 18:11:30 by vnakonec ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
#include "./ft_printf.h"
char *ft_strstr(const char *s1, const char *s2)
{
int i;
int b;
char *str;
char *str2;
i = 0;
str = (char *)s1;
str2 = (char *)s2;
while (str[i] != '\0')
{
b = 0;
while (str2[b] == str[i + b])
{
if (str2[b + 1] == '\0')
return (str + i);
b++;
}
i++;
}
if (ft_strlen(str2) == 0)
return (str);
return (NULL);
}