ft_strstr, norming ft_strchr, ft_strrchr

This commit is contained in:
Tanguy MAZE 2018-04-05 11:24:30 +02:00
parent c94e1f448e
commit aa17bb3c11
4 changed files with 41 additions and 8 deletions

View File

@ -6,7 +6,7 @@
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ # # By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# # # Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
# Updated: 2018/04/05 10:41:34 by tmaze ### ########.fr # # Updated: 2018/04/05 11:06:04 by tmaze ### ########.fr #
# # # #
#******************************************************************************# #******************************************************************************#
@ -25,6 +25,7 @@ SRCS = \
ft_strncat.c \ ft_strncat.c \
ft_strchr.c \ ft_strchr.c \
ft_strrchr.c \ ft_strrchr.c \
ft_strstr.c \
ft_isalpha.c \ ft_isalpha.c \
ft_isdigit.c \ ft_isdigit.c \
ft_isalnum.c \ ft_isalnum.c \

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */ /* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */
/* Updated: 2018/04/05 10:25:13 by tmaze ### ########.fr */ /* Updated: 2018/04/05 11:05:16 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */ /* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 10:40:13 by tmaze #+# #+# */ /* Created: 2018/04/05 10:40:13 by tmaze #+# #+# */
/* Updated: 2018/04/05 10:41:19 by tmaze ### ########.fr */ /* Updated: 2018/04/05 11:05:31 by tmaze ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

32
ft_strstr.c Normal file
View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 10:54:41 by tmaze #+# #+# */
/* Updated: 2018/04/05 11:19:02 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *haystack, const char *needle)
{
int i;
int j;
char *tmp;
i = -1;
tmp = (char*)haystack;
while (++i == 0 || tmp[i - 1])
if (tmp[i] == needle[0] && (j = 1))
{
while (tmp[i + j] == needle[j] && needle[j] && tmp[i + j])
j++;
if (needle[j] == '\0')
return (&tmp[i]);
}
return (NULL);
}