maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strstr.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_strstr.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/12/17 17:25:27 by rmikhayl #+# #+# */
9
/* Updated: 2023/12/17 17:25:27 by rmikhayl ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
/* *************************** ft_strstr ************************************ */
16
/* Searches for the first occurrence of 'little' within 'big,'. */
17
/* Returns a pointer to the found substring or NULL if not found. */
18
/* */
19
/* */
20
/* In layman's terms: It's like looking for a specific word or phrase in a */
21
/* longer text. If it's there, you get a pointer to it, otherwise NULL. */
22
/* ************************************************************************** */
23
24
char
*
ft_strstr
(
const
char
*big,
const
char
*little)
25
{
26
size_t
little_len;
27
28
if
(!big)
29
return
(NULL);
30
little_len =
ft_strlen
(little);
31
if
(little[0] ==
'\0'
)
32
return
((
char
*)big);
33
while
(*big !=
'\0'
)
34
{
35
if
(
ft_strncmp
(big, little, little_len) == 0)
36
return
((
char
*)big);
37
big++;
38
}
39
return
(NULL);
40
}
ft_strstr
char * ft_strstr(const char *big, const char *little)
Definition
ft_strstr.c:24
libft.h
ft_strncmp
int ft_strncmp(const char *s1, const char *s2, size_t n)
Definition
ft_strncmp.c:24
ft_strlen
size_t ft_strlen(const char *s)
Definition
ft_strlen.c:15
lib
libft
src
ft_strstr.c
Generated by
1.9.8