Push libft

125/100 corrected the 14/11/23
This commit is contained in:
Raphaël 2023-11-14 13:31:56 +01:00 committed by GitHub
commit 7bd66aee5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1462 additions and 0 deletions

37
ft_strnstr.c Normal file
View 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);
}