mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 19:36:50 +01:00
36 lines
1.3 KiB
C
36 lines
1.3 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strnstr.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2023/11/08 16:02:17 by adjoly #+# #+# */
|
||
|
/* Updated: 2024/02/04 14:48:22 by adjoly ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "../libft.h"
|
||
|
|
||
|
char *ft_strnstr(const char *big, const char *little, size_t len)
|
||
|
{
|
||
|
size_t i;
|
||
|
size_t j;
|
||
|
|
||
|
i = 0;
|
||
|
if (!big && len == 0)
|
||
|
return (NULL);
|
||
|
if (*little == '\0' || little == big)
|
||
|
return ((char *)big);
|
||
|
while (i < len && big[i])
|
||
|
{
|
||
|
j = 0;
|
||
|
while (big[i + j] == little[j] && little[j] && big[i] && i + j < len)
|
||
|
j++;
|
||
|
if (little[j] == 0)
|
||
|
return ((char *)big + i);
|
||
|
i++;
|
||
|
}
|
||
|
return (NULL);
|
||
|
}
|