-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strstr.c
executable file
·40 lines (36 loc) · 1.31 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
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mwilliam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/08 16:25:05 by mwilliam #+# #+# */
/* Updated: 2016/12/09 12:33:56 by mwilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Locates the first occurence of the string "little" in the string "big"
*/
char *ft_strstr(const char *big, const char *little)
{
const char *big2;
const char *little2;
if (*little == '\0')
return ((char *)big);
while (*big)
{
big2 = big;
little2 = little;
while (*big2 == *little2 && *big2)
{
big2++;
little2++;
}
if (*little2 == '\0')
return ((char *)big);
big++;
}
return (NULL);
}