maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strnstr.c File Reference
#include "libft.h"
Include dependency graph for ft_strnstr.c:

Go to the source code of this file.

Functions

char * ft_strnstr (const char *big, const char *little, size_t n)
 

Function Documentation

◆ ft_strnstr()

char * ft_strnstr ( const char *  big,
const char *  little,
size_t  n 
)

Definition at line 25 of file ft_strnstr.c.

26{
27 size_t little_len;
28
29 if (!big && n == 0)
30 return (NULL);
31 little_len = ft_strlen(little);
32 if (little[0] == '\0')
33 return ((char *)big);
34 while (*big != '\0' && n >= little_len)
35 {
36 if (ft_strncmp(big, little, little_len) == 0)
37 return ((char *)big);
38 big++;
39 n--;
40 }
41 return (NULL);
42}
int ft_strncmp(const char *s1, const char *s2, size_t n)
Definition ft_strncmp.c:24
size_t ft_strlen(const char *s)
Definition ft_strlen.c:15

References ft_strlen(), and ft_strncmp().

Here is the call graph for this function: