libft/sources/libft_srcs/ft_strnstr.c
char	*ft_strnstr(const char *haystack, const char *needle, size_t len)
{
	size_t	i;
	size_t	j;

	i = 0;
	if (needle[i] == '\0' && len == 0)
		return ((char*)haystack);
	while (haystack[i] != '\0' && i < len)
	{
		j = 0;
		while (haystack[i + j] == needle[j] && needle[j] != '\0')
			j = j + 1;
		if (needle[j] == '\0' && (i + j) <= len)
			return ((char*)&haystack[i]);
		i = i + 1;
	}
	return (NULL);
}
/*
** The strnstr() function locates the first occurrence of the null-terminated
** string needle in the string haystack, where not more than len characters are
** searched.  Characters that appear after a `\0' character are not searched.
** Since the strnstr() function is a FreeBSD specific API, it should only
** be used when portability is not a concern.
*/
The strnstr() function locates the first occurrence of the null-terminated
string needle in the string haystack, where not more than len characters are
searched.  Characters that appear after a `\0' character are not searched.
Since the strnstr() function is a FreeBSD specific API, it should only
be used when portability is not a concern.
The strnstr () function locates the first occurrence of the null - terminated string needle in the string haystack where not more than len characters are searched . Characters that appear after a ` \ 0 ' character are not searched . Since the strnstr () function is a FreeBSD specific API it should only be used when portability is not a concern .
char	*ft_strnstr(const char *haystack, const char *needle, size_t len)
{
	size_t	i;
	size_t	j;
	i = 0;
	if (needle[i] == '\0' && len == 0)
		return ((char*)haystack);
	while (haystack[i] != '\0' && i < len)
	{
		j = 0;
		while (haystack[i + j] == needle[j] && needle[j] != '\0')
			j = j + 1;
		if (needle[j] == '\0' && (i + j) <= len)
			return ((char*)&haystack[i]);
		i = i + 1;
	}
	return (NULL);
}
char * ft_strnstr ( const char * haystack , const char * needle , size_t len ) { size_t i ; size_t j ; i = 0 ; if ( needle [ i ] == ' \0 ' && len == 0 ) return ( ( char * ) haystack ) ; while ( haystack [ i ] != ' \0 ' && i < len ) { j = 0 ; while ( haystack [ i + j ] == needle [ j ] && needle [ j ] != ' \0 ' ) j = j + 1 ; if ( needle [ j ] == ' \0 ' && ( i + j ) <= len ) return ( ( char * ) & haystack [ i ] ) ; i = i + 1 ; } return ( NULL ) ; }
The strnstr() function locates the first occurrence of the null-terminated
string needle in the string haystack, where not more than len characters are
searched.
The strnstr () function locates the first occurrence of the null - terminated string needle in the string haystack where not more than len characters are searched .