Push libft
125/100 corrected the 14/11/23
This commit is contained in:
commit
7bd66aee5b
45 changed files with 1462 additions and 0 deletions
37
ft_strnstr.c
Normal file
37
ft_strnstr.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strnstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */
|
||||
/* Updated: 2023/11/13 19:17:49 by rparodi ### ########.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 (len == 0 && (!big || !little))
|
||||
return (NULL);
|
||||
if (!little[i])
|
||||
return ((char *)big);
|
||||
while (big[i] && i < len)
|
||||
{
|
||||
j = 0;
|
||||
while (i + j < len && little[j] == big[i + j])
|
||||
{
|
||||
j++;
|
||||
if (little[j] == '\0')
|
||||
return ((char *)(big + i));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue