This commit is contained in:
rzy
2026-08-31 02:16:33 +02:00
commit 94cd5aac51
25 changed files with 705 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/08/23 23:27:28 by rzy #+# #+# */
/* Updated: 2026/08/23 23:33:18 by rzy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *haystack, const char *needle, size_t n)
{
size_t i;
size_t j;
if (!needle[0])
return ((char *)(haystack));
i = 0;
while (i < n && haystack[i])
{
j = 0;
while (i + j < n && needle[j] && haystack[i + j] == needle[j])
++j;
if (!needle[j])
return ((char *)&haystack[i]);
++i;
}
return (NULL);
}