makefile a la norme

This commit is contained in:
Hugo LAMY
2019-12-03 17:47:29 +01:00
parent 90106ef3ae
commit 41e56fce3b
75 changed files with 42 additions and 51 deletions

42
srcs/part1/ft_strnstr.c Normal file
View File

@@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 13:58:10 by hulamy #+# #+# */
/* Updated: 2019/11/25 13:58:11 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
/*
** locate the first occurence of the string little in len first characters
** of big and return a pointer to this occurence if found
*/
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
size_t j;
j = 0;
i = 0;
if (!ft_strlen(little))
return ((char *)big);
while (i == 0 && j <= len)
{
while (little[i] == big[j + i] && little[i] && j + i <= len)
i++;
if (little[i])
{
j++;
if (!big[j] || j >= len)
return (0);
i = 0;
}
}
return ((char *)big + j);
}